• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate only fetching the last in from an object's collection and not the whole collection?

 
David Rocks
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this possible?

I have an object that holds a collection (a large one).



I am only interested in the last object in ( PK will be max ) is there a way to get a collection containing only the last one in or a way to have an single object that is populated with the last one in using annotations?

Thanks in advance for any help.
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Annotations I do not think so, You could use a NamedQuery instead.
 
David Rocks
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Checking the docs I think I max be able to do it using

@BAtchSize and setting up and @OrderBy to return last first.
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be aware that every time you call the collections, it will come with the same results. If you want to see all the results you would need to create a new attribute or use a query.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic