[jboss-user] [EJB 3.0] - Re: eager vs. lazy fetching

mazz@jboss.com do-not-reply at jboss.com
Thu Feb 22 13:09:46 EST 2007


So, Itemgroup has an items relationship that is lazy loaded.  Your findItemGroup is only loading in the Itemgroup entity without doing any fetch joining or eagerly loading of that relationship, hence your error.

you will need to have another method, "findItemGroupWithItems" or something like that.  In that method you execute a query that does a JOIN FETCH, rather than use find().  Or you can do a find and then (still in findItemGroupWithItems method) immediately force the loading to happen by calling itemgroup.getItems().size() (this causes a second round trip to the database - not as efficient but easy to code up).

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

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



More information about the jboss-user mailing list