Hello,
I'm trying to port a JPA based, standalone application to Hibernate but I'm heavily struggling with the following problem:
The documentation for Hibernate EntityManager clearly states (see
http://docs.jboss.org/hibernate/stable/ ... tions.html):
"The Hibernate Entity Manager may be disconnected from the underlying JDBC connection between two client calls and reconnected when a new client request occurs. This pattern is known as entitymanager-per-application-transaction and makes even merging unnecessary. An extend persistence context is responsible to collect and retain any modification (persist, merge, remove) made outside a transaction. The next client call made inside an active transaction (typically the last operation of a user conversation) will execute all queued modifications. Automatic versioning is used to isolate concurrent modifications."
Furthermore:
"All application managed entity manager and container managed persistence contexts defined as such are EXTENDED. This means that the persistence context type goes beyond the transaction life cycle. We should then understand what happens to operations made outside the scope of a transaction."
Obviously this doesn't work. When I try to modify an entity that was loaded earlier (outside a Transaction) a javax.persistence.PersistenceException("detached entity passed to persist: net.uniopt.domain.config.SettingSpec") is thrown.
Does Hibernate actually support an extended persistence context?
What's missing to get the correct behavior?
Do I have to use the entitymanager-per-request pattern with Hibernate, even if this contradicts the Java Persistence API?
Kind Regards,
Abbzug