• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Select an entity object in a NamedQuery

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to return an entity object from a NamedQuery and I am having trouble.


So I want to return a row from the Revision table but where the row is equal to the passed in id (from the Test table) and has the max revision from the revision table. This NamedQuery almost does the trick but I am returning the max revision number from the revision table and not the actual revision entity.

 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What if you put the Max part into your where clause instead, using a subquery. So


If you want the Revisions collection in Test to be populated, then you ...

Wait which entity do you want back. It looks like you want the Revision object back. So



What is your mapping for this relationship, show bot Revision and Test, I am making some assumptions up there in the query that might be slightly off. But I hope you get my idea of the MAX being in a subquery.

Mark
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic