[seam-issues] [JBoss JIRA] (SEAMPERSIST-67) LazyInitializationException threw when persist a Many to Many collection of an entity.

Jason Porter (Commented) (JIRA) jira-events at lists.jboss.org
Thu Dec 1 13:39:40 EST 2011


    [ https://issues.jboss.org/browse/SEAMPERSIST-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12647273#comment-12647273 ] 

Jason Porter commented on SEAMPERSIST-67:
-----------------------------------------

The problem is a JSF problem. In your selectManyCheckBox you need to set the collectionType attribute to the java.util collection type. Mojarra creates a new instance of type to set the new values to. Either this is a new instance of the type given in collectionType or the *concrete type* of the actual collection. In this case it was the Hibernate PersistentBag. So Mojarra creates a new instance of the class and sets the objects on that. Of course Hibernate can't use that instance to persist with because it doesn't know anything about it, it was created outside of Hibernate.

That's the core of the issue. When you fix that you also have to set the objects on both sides of the many to many collection. In the github app you posted you have to set the post on the tag(s) as well as the tag(s) on the post. Then see things persisting correctly.

I also found another bug while going through this: SEAMFACES-224
                
> LazyInitializationException threw when persist a Many to Many collection of an entity.
> --------------------------------------------------------------------------------------
>
>                 Key: SEAMPERSIST-67
>                 URL: https://issues.jboss.org/browse/SEAMPERSIST-67
>             Project: Seam Persistence
>          Issue Type: Bug
>         Environment: Java 6 update 27, Seam 3.1.0Beta2, JBoss 7.0.1.Final
>            Reporter: hantsy bai
>            Priority: Critical
>
> I tried a saved a many to many relation(multicheckbox), but failed.
> But in before seam 2 application, I used like this, never encounter such a problem.
> I used Seam managed Persistence, and added TransactionIntercepter in the beans.xml.
> Please refer the discussion in the forum.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the seam-issues mailing list