aspose file tools*
The moose likes Object Relational Mapping and the fly likes how to set fetch type at runtime ? + Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "how to set fetch type at runtime ? + Hibernate" Watch "how to set fetch type at runtime ? + Hibernate" New topic
Author

how to set fetch type at runtime ? + Hibernate

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 751
How can we set the fetch type at runtime



Jigar Naik


Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You can specify it in your query.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968


Here's an example of fetching associated properties in an eagar manner at runtime. Without an HQL query, I don't believe there's anything you can do to dynamically change the FetchType that has been set in a mapping or through a Java Persistence API (JPA) annotation.


from Sale sale
where sale.date > :startDate
left join fetch sale.salesman
left join fetch sale.product
left join fetch sale.product.color
left join fetch sale.product.category


Setting FetchType to Eagar at Runtime with a Hibernate Query

-Cameron McKenzie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to set fetch type at runtime ? + Hibernate
 
Similar Threads
hibernate one to many reationship.
Lazy Loading
how to display database values in a table
not able to retrive updated data from session using session.load + hibernate
db2 type 4 driver result set fetch size