• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Select an entity object in a NamedQuery

 
Bobby Anderson
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • 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.

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic