0 Replies Latest reply on Jul 18, 2013 5:34 AM by raickman

    Session is closed.

    raickman

      Hi,

       

      I am using Jboss 7.1.1 Final and my application embeds Hibernate 3.5. 

       

      When saving an object MyClass containing these 2 realtions, I have the following exception. 

       

      @Entity

      @Audited

      public class MyClass{

       

       

      @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)

      @JoinColumn(name = "user_id")

      private User user;

       

      @OneToMany(cascade = ALL)

      @JoinColumn(name = "agent_id")

      private List<AgentCode> agentCodes;

       

      }

       

      In AgentCode, I have the mappedBy attribute:

       

      @ManyToOne

      @AuditMappedBy(mappedBy = "agentCodes")

      private Agent agent;

       

       

      When agentCodes list is empty and firstly filled with one or several items, it works.  But when I try to save a third one, when the List is already containing AgentCodes, I get the exception. 

       

      I have debugged the Envers code and for the User property, it doesn't use the temporary session of AuditSync but the SessionImplementor whose session is already closed.

       

      Caused by: org.hibernate.SessionException: Session is closed!

                at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:72) [hibernate-core-3.5.0-Final.jar:3.5.0-Final]

                at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1473) [hibernate-core-3.5.0-Final.jar:3.5.0-Final]

                at org.hibernate.envers.tools.Tools.getIdentifier(Tools.java:67) [hibernate-envers-3.5.0-Final.jar:3.5.0-Final]

                at org.hibernate.envers.tools.Tools.entitiesEqual(Tools.java:50) [hibernate-envers-3.5.0-Final.jar:3.5.0-Final]

                at org.hibernate.envers.entities.mapper.relation.ToOneIdMapper.mapToMapFromEntity(ToOneIdMapper.java:71) [hibernate-envers-3.5.0-Final.jar:3.5.0-Final]

                at org.hibernate.envers.entities.mapper.MultiPropertyMapper.mapToMapFromEntity(MultiPropertyMapper.java:107) [hibernate-envers-3.5.0-Final.jar:3.5.0-Final]

                at org.hibernate.envers.synchronization.work.CollectionChangeWorkUnit.generateData(CollectionChangeWorkUnit.java:56) [hibernate-envers-3.5.0-Final.jar:3.5.0-Final]

                at org.hibernate.envers.synchronization.work.AbstractAuditWorkUnit.perform(AbstractAuditWorkUnit.java:68) [hibernate-envers-3.5.0-Final.jar:3.5.0-Final]

                at org.hibernate.envers.synchronization.AuditSync.executeInSession(AuditSync.java:119) [hibernate-envers-3.5.0-Final.jar:3.5.0-Final]

                at org.hibernate.envers.synchronization.AuditSync.beforeCompletion(AuditSync.java:149) [hibernate-envers-3.5.0-Final.jar:3.5.0-Final]

                at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76)

                at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:273)

                at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:93)

                at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:164)

                at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1165)

                ... 76 more

       

       

      Any help would be appreciated because it s been 3 days now I am trying to fix this issue :s

       

      Thanks