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 8780217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:59:10+00:00 2026-06-13T19:59:10+00:00

I have the following scenario, Domain class A which hasMany B’s Domain class B

  • 0

I have the following scenario,

Domain class A which hasMany B's
Domain class B which hasMany C's and belongsTo A
Domain class C which belongsTo B

Class E {
 A a
 B b
 C c

 }
 Class C {
  String name
 }

I want to query E values i.e get a list of some E property eg in this case c.name based on values selected by a user in a select box, i.e user selects A and B from multiple select boxes and based on this criteria, a list of names is obtained.

in other words i want to find all names in c which satisfy condition set by a and b

have tried to figure out the GORM query to no avail.

thanks

  • 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-13T19:59:11+00:00Added an answer on June 13, 2026 at 7:59 pm

    I solved this by using raw SQL joins. Not really certain if this was the best way but it worked for me.
    I got the parameters from A and B, ie

    def fromA = params.someCriteriaValueInA
    def fromB = params.someCriteriaValueInB
    

    Please note that these are fetched from a gsp. Also, fromB values would be loaded based on fromA values, using chained selects.

    In the grails controller/service …

    def db = new Sql(dataSource)
    def result = db.rows("your sql to go here")
    

    Then you can do whatever you want with the results, for example manipulate it in a template

    render(template: "myResults", model:[result :result])
    

    Dont forget to inject the dataSource bean in your controller/service, and also doing the necessary import

    import groovy.sql.Sql
    

    Please note that this involved traversing many domain class instances, and for those who like raw SQL this would seem easier.Would appreciate a different approach, maybe using GORM’s criteria.

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

Sidebar

Related Questions

I have the following scenario where I want to pass in string and a
Following is the scenario. I have something called as Domain which can have multiple
I have the following scenario :- template <typename T> class Base { public: virtual
I have the following scenario, class foo { ... private: char *_test; }; void
I have the following domain class: public class Product { public virtual Guid Id
I have a scenario where I want to get the single sign on experience
I have following scenario: alt text http://static.zooomr.com/images/7579022_e64808b855_o.png We have a WebService which poses as
I have the following scenario where I have a page say parentPage.html, which contains
I have the following scenario: I want to pass a parameter to a page
I am trying to understand isolation/locks in SQL Server. I have following scenario in

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.