Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8311415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:48:32+00:00 2026-06-08T19:48:32+00:00

in few places in my code I query db using def results = Domain.findAllBySomething

  • 0

in few places in my code I query db using def results = Domain.findAllBySomething and I expect an array (i use results.size() to determine how many results I have).
However, if findAll call results in a single object returned, it will not be returned as array but a reference to this single object.

Is there any way I could force grails to always return array, no matter how many results there are?

I’m using 2.1.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:48:34+00:00Added an answer on June 8, 2026 at 7:48 pm

    findAll* is supposed to always return a Collection – I tried the following code in 2.1:

    def person = Person.findAllByName('kelly')
    println person.size()
    println person.class
    println person[0].name
    

    prints

    1
    class java.util.ArrayList
    kelly
    

    Can you add some code that shows it returning a single instance?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a few places in our code we use #if DEBUG blocks to simplify
I have a few specific places in my code where I use specific pixel
I have a few places in the code where I need to use the
I've read in a few places now that the maximum instance size for a
I have a few places in my code where I have nested objects, but
There are a few minor places where code for my project may be able
I have seen code with the following logic in a few places: public void
I'm refactoring some code. Right now there are quite a few places with functions
I'm reviewing some javascript code and the programmer uses >> in a few places.
I have a few places where I use the line below to clear out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.