File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 759
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
    
    1


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