Search code examples
hibernatejboss7.xseamentitymanagerhibernate-entitymanager

JPA EntityManager hibernate exception "detached entity passed to persist" due to timeout error


I support an application that often saves huge amount of data to database during a persist operation. The application runs smoothly for less amount of data. But when I try to persist huge amount of data, after a period of 30 min, it throws the hibernate exception "detached entity passed to persist"

I searched around for various explanations for this, and found that this can occur due to mainly two reasons:

  1. Incorrectly written code/incorrectly defined entity
  2. The object being detached after certain amount of timeout

I am confident that it is not a code issue as the application has been running without issues for less amount of data.

Assuming it's a timeout issue, I am not sure where the timeout is defined, and which timeout it is that decides when the object should be detached.

Any help would be appreciated. We use Hibernate, Seam, and JBoss 7 to run the application


Solution

  • After a lot of trial and errors I found out that it can be changed by modifying coordinator-environment default-timeout in standalone.xml as below:

    <subsystem xmlns="urn:jboss:domain:transactions:1.3"> <core-environment> <process-id> <uuid/> </process-id> </core-environment> <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/> <coordinator-environment default-timeout="300"/> </subsystem>