Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 17346
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
 
Can't .... do .... plaid .... So I did this tiny ad instead:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic