• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

missing property FetchType.EAGER in entityManger.find ?

 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does JPA2 has any method something like:



So I do not need to set up all my relationships within Users-class to fetchtype.eager.



 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Its usually the exception rather than the rule to define collections to be eagerly fetched, this is because it is easy to override fetching behaviour in a specific query, but the performance overhead of always bringing back a whole object graph is not usually desirable (though this may be different in your case).

Its easy enough to write a method to do what you want though. Your DAO class could create a query by id as required which would be what I'd recommend.
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, I can create a query for that.

However, it would be nice to have such a feature to find-Method. Maybe in jpa3..;)

thanks.
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JPA does not, but some providers do.

With JPA you could use a JPQL query that uses join fetch to make relationships fetched.

With EclipseLink you can use a LoadGroup or FetchGroup with a query through a query hint that defines what you wish to be loaded.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!