Hi, I'm new to hibernate and I'm having a problem of Illegal attempt to associate a collection with two open sessions. I'm working with Hibernate 3.3 in JTA mode with Jboss and already configured hibernate.transaction.factory_class to org.hibernate.transaction.JTATransactionFactory and hibernate.transaction.manager_lookup_class to org.hibernate.transaction.JBossTransactionManagerLookup.
I have two session beans that can access and use the same entity at the same time. For performance reason my original idea was to keep this object in memory and reattach it with session.update when I have to use it, but I'm having this problem of Illegal attempt to associate a collection with two open sessions, cause both of the session beans appeared to have a different session automatically attach to them (because of JTA).
I tried using LockMode.UPGRADE before session.update, trying to lock the entity before using to avoid the second session bean accessing the object at the same time; but is throwing the same exception. The entity I'm using has of course a collection of objects that I suppose is generating this error.
What is the best strategy to work with this? Synchcronize access to the parent entity? Evict the object after using it?
Thanks in advance mates!!!
|