[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - turn off eager fetch selectively at the query level (Criteri

karthikg do-not-reply at jboss.com
Tue May 22 06:52:10 EDT 2007

I have a POJO that has relationships with other POJOs. The relationships are marked for eager fetch-ing. 

For some of the use cases, i want to turn OFF the eager fetch. So I tried using native SQL with automatic resultset mapping.

This still results in the eager fetching of relationships.

session.createSQLQuery("select * from Organization").addEntity(Organization.class).list() ;//get me only org data

--> This causes the relationships to be fetched as well. How can i turn it off.?

I tried using the Criteria API as well - 
 Criteria 	setFetchMode(String associationPath, FetchMode mode) 

This doesn't turn OFF eager fetch either.

what should be the FetchMode to turn of EAGER fetch?
FetchMode.EAGER is deprecated. It recommends use of FetchMode.SELECT which actually gets the data in a separate SQL! Now that is not what i require. I want to turn it off.

Any help would be greatly appreciated


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047512#4047512

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047512

More information about the jboss-user mailing list