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

  • Home
  • SEARCH
  • 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 8508861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:16:42+00:00 2026-06-11T03:16:42+00:00

Using grails 2.1.0 and default H2 database. I’ve got the following domains: class Project

  • 0

Using grails 2.1.0 and default H2 database. I’ve got the following domains:

class Project {
    static hasMany = [tasks: Task]
}

class Task {
    Date dateCreated
    static belongsTo = [project: Project]
}

I’ve got a task id and want to get all tasks from the task’s (of the given id) project, using the all-new gorm where queries. Here’s my attempt:

def tasks = Task.where {
    project == property('project').of { id == firstTask.id }
}.list()

(firstTask.id is the given task id, the code is snipped from a test)

And the unpleasant unexpected result is:

IllegalArgumentException occurred calling getter of so.q.grom.subqueries.Project.id
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of so.q.grom.subqueries.Project.id
    at grails.gorm.DetachedCriteria.list_closure2(DetachedCriteria.groovy:639)
    at grails.gorm.DetachedCriteria.withPopulatedQuery_closure9(DetachedCriteria.groovy:890)
    at org.grails.datastore.gorm.GormStaticApi.withDatastoreSession_closure18(GormStaticApi.groovy:555)
    at org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:301)
    at org.grails.datastore.gorm.AbstractDatastoreApi.execute(AbstractDatastoreApi.groovy:34)
    at org.grails.datastore.gorm.GormStaticApi.withDatastoreSession(GormStaticApi.groovy:554)
    at grails.gorm.DetachedCriteria.withPopulatedQuery(DetachedCriteria.groovy:873)
    at grails.gorm.DetachedCriteria.list(DetachedCriteria.groovy:638)
    at grails.gorm.DetachedCriteria.list(DetachedCriteria.groovy:637)
    at GormSubqueriesSpec.should get tasks from the same project(GormSubqueriesSpec.groovy:32)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
    ... 10 more

Why!? 🙁 How’s that different from:

def tasks = Task.findAll() {
    dateCreated < property('dateCreated').of { id == secondTask.id }
}

To clarify, using HQL, what I want would be:

def tasks = Task.findAll(
        'from Task task where task.project = (select t.project from Task t where t.id = :taskId)',
        [taskId: firstTask.id]
)

But I want it in “where queries”.

For Your convenience (and me being precise), a Grails project with the domains and tests for the queries is available here

  • 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-11T03:16:43+00:00Added an answer on June 11, 2026 at 3:16 am

    You should raise this as an issue. The following example compiles and runs:

    def tasks = Task.where {
        project == property('project')
    }.list()
    

    but adding a sub-query causes problems. At the very least, the error message should be more informative. But I don’t see why it couldn’t work in theory.

    Anyway, in the meantime HQL is probably your best bet.

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

Sidebar

Related Questions

I want to create war using grails, but by default it creates war file
Using Grails database-migration I have a table in production defined like so: +--------------+------------+------+-----+---------+----------------+ |
When using Grails 1.1 together with a MySQL the charsets of the auto-generated database
I was using grails 1.3.4 for my project and everything was working fine until
I'm considering using Grails for my current project. I have a couple of requirements
I'm using Grails scaffolding and would like to make a change in the default
Using Grails 2.0.0 I am created service, that creates instances of Player class and
I have a grails project and my configuration points to a mysql database: DataSource.groovy
When using Grails 1.0.4 together with a MySQL the charsets of the auto-generated database
Using Grails 2.0.x and the spring security plugin with the default @Secured annotations how

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.