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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:54:56+00:00 2026-06-05T22:54:56+00:00

I have a relationship like this class Foo { static hasMany = [bars: Bar,

  • 0

I have a relationship like this

class Foo {
    static hasMany = [bars: Bar, things: Thing]
}

class Bar {
    // Has nothing to tie it back to Foo or anything else of importance
}

class Thing {
    // Has nothing to tie it back to Foo or anything else of importance
}

I have an instance of Thing. I want to get all instances of Bar that are associated with all instances of Foo that are associated with the instance of Thing that I have.

I have used Grails executeQuery method several times but my query does not work.

Here is a working query that will get all instance of Foo related to an instance of Bar. I expect the query I need will look very similar, I’m just having trouble with the HQL joins.

SELECT DISTINCT f FROM Foo f INNER JOIN f.bars bars WHERE bars =:bars
  • 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-05T22:54:57+00:00Added an answer on June 5, 2026 at 10:54 pm
    SELECT DISTINCT f.Bars FROM Foo f inner join f.things thing where thing.Id in (:validThingIds)
    

    grails should support setting parameters and you basically need to pass the array of ids to the query.. The final part of the query should evaluate to (1,2,3,4) where 1,2,3,4 are the ids of the valid things.

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

Sidebar

Related Questions

I have a relationship like this: class E { string name hasMany = [me:ME]
I have a JPA object which has a many-to-many relationship like this: @Entity public
I have a model with a relationship like this: class Category < ActiveRecord::Base has_many
I have bi-directional relationship like this... Person.java public class Person{ @JsonIgnore @OneToMany(targetEntity=PersonOrganization.class, cascade=CascadeType.ALL, fetch=FetchType.EAGER,
I have a many-to-many relationship like this: class Event < ActiveRecord::Base has_many :calendar_events has_many
I have a basic Core data model like this: Class -Class Name (string) Relationship:
Let say I have a class like this: public sealed class Foo { public
I have a relationship like this class User include Mongoid::Document include Mongoid::Timestamps embeds_one :setting
I have a many-to-many relationship like this: A user has_many organizations through affiliations and
I'm using Hibernate with JPA and have a relationship that looks like this: public

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.