I agree that lazy instantiation is the best way to go, but my problem with the 
lazy instantiation is that I have trouble keeping my objects in the session. My 
seam action classes call my business layer to get all objects:

i.e. List clients=clientService.findByLastName("Doe");

This works fine to display the search results, but when I click a detail row to 
go to the detail page I get lazy initialization errors:

client.getPolicies(); <-- produces lazy initialization error.

I think the problem is that the call to the entity manager is buried in my DAO 
layer and is not in the action itself. In other words, my action calls the 
business layer which in turn calls the DAO layer to get the object.  Because 
the EntityManager is not in the action I get lazy initialization errors, is 
this correct? Am I going about this all wrong?

I know there must be a way to do this, but others have complained about this 
problem as well: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=62275

I cannot quite understand how to keep the object in the session between pages I 
keep getting LazyInitialization errors on all subsequent pages. What am I doing 
wrong?

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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056883
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to