[jboss-user] [JBoss Seam] - How to modify a detached entity

jgreene do-not-reply at jboss.com
Thu Oct 11 22:45:05 EDT 2007


Hi -
I've read about Seam's support for an extended persistence context, and have read about Seam conversations.  I've got a Lazy Initialization problem that doesn't seem to quite fit the solutions I've read about - maybe I just can't quite see it.

I've got an entity object with a lazy loaded collection.  The entity has Session scope, and is created early in the application.  The main page of the app has a link that the user can click at any time that displays a Richfaces modal panel form used to modify the property values in both the entity object as well as its collection.  Everything displays fine in the modal panel, so the collection is loaded successfully by hibernate.

However, when I try to save any changes with a button click on the form and a bean save action using a stateful session bean, I call entityManager.merge(myEntity), and that's where I get a LazyInitializationException.  All values both in the entity and the collection are correct in the entity, but I guess since the object is no longer attached to a hibernate session, the merge does not work.

Is there a preferred way to attach this object to a hibernate session without explicitly using code to get a session, start a transaction, etc.?  From what I've read, this is of course a common pattern, but the solutions seem to involve more explicit coding than I would expect to have to do.

This is my first Seam project, so maybe there's a quick, easy solution here that will get me past this sticking point.  I can provide a few code snippets, but I think this is such a common problem, I'm betting I won't need any.

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

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



More information about the jboss-user mailing list