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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:46:19+00:00 2026-06-01T09:46:19+00:00

I have been spending some time on this. My problem involves bringing back domain

  • 0

I have been spending some time on this. My problem involves bringing back domain objects with certain criteria and conditions:

I have a large set of bikes. There is a possibility of having multiple bikes with similar wheel size. For example I can have 5 bikes:

owner_id | bike | wheel | price | active | toolset | forLance
_________|______|_______|_______|________|_________|__________
15459    |liner |    12 |  100  |     Y  |   null  |   H       
15459    |larker|    15 |  150  |     Y  |   null  |   H      
15459    |jefro |    21 |  225  |     Y  |   null  |   H      
15459    |raz   |    21 |  230  |     Y  |   null  |   L      
15459    |jynx  |    21 |  295  |     Y  |   null  |   P      

My query below retrieves the all the bikes with non-duplicate wheel size and lowest price.

MySQL query:

select * from bike b 
where b.owner_id = 15459 
and not exists( select * from bike 
where wheels = b.wheels AND price < b.price 
and owner_id = b.owner_id)  and b.active = 'Y';

The result will give me the rows with the bikes : liner, larker, and jefro.

Is there an equivalent way to do this in grails//groovy? ( Get liner, larker, and jefro into a list of domain objects)

I have tried using a structure like:

def bikes = Bike.executeQuery(...)
or
def bike = Bike.findAll(...)

But I cannot seem to execute a query with a similar structure to the MySQL script I made.

Thanks for the help!

  • 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-01T09:46:20+00:00Added an answer on June 1, 2026 at 9:46 am

    In your MySQL you are using subqueries to retrieve the data. AFAIK this is not possible with GORM. What you could do is writing it in Hibernate Query Language (HQL)

    Lets assume your Domain Class is called Bike.

    Bike.findAll("from Bike as b where b.active = 'Y' and b.owner = :owner and b.id in elements(select b1.id from Bike where b1.owner = :owner and b1.active = 'Y' and b1.price < b.price)", ['owner':owner])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been spending some time playing with Clojure-CLR. My REPL is working, I
Despite spending some time trawling the MS websites, I have not been able to
I have been having a problem with this belimy hair for not sending products
I've been spending some time refactoring my C# code, and I'm struck by how
I've been spending some time looking at Phil Haack's article on Grouping Controllers very
have been sitting with this problem for a few days and really can't seem
Well, I have been scratching my head for some time now. But failed to
Have been working on this question for a couple hours and have come close
Have been looking on some tutorials for drawing canvas using SurfaceView, but the only
I have been tasked with refactoring some components that used xmlbeans to now make

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.