mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 00:24:57 +00:00
HHH-10952 - Tests leaving transactions opened cause PostgreSQL to hang
This commit is contained in:
parent
468307f394
commit
1da8f01740
@ -261,28 +261,10 @@ protected EntityManager getOrCreateEntityManager() {
|
||||
}
|
||||
|
||||
protected AuditReader getAuditReader() {
|
||||
EntityManager entityManager = getOrCreateEntityManager();
|
||||
SessionImplementor sessionImplementor = entityManager.unwrap( SessionImplementor.class );
|
||||
|
||||
if ( sessionImplementor.getTransactionCoordinator().getTransactionCoordinatorBuilder().isJta() ) {
|
||||
if ( !JtaStatusHelper.isActive( TestingJtaPlatformImpl.INSTANCE.getTransactionManager() ) ) {
|
||||
try {
|
||||
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( !entityManager.getTransaction().isActive() ) {
|
||||
entityManager.getTransaction().begin();
|
||||
}
|
||||
|
||||
if ( auditReader != null ) {
|
||||
return auditReader;
|
||||
}
|
||||
|
||||
return auditReader = AuditReaderFactory.get( entityManager );
|
||||
return auditReader = AuditReaderFactory.get( getOrCreateEntityManager() );
|
||||
}
|
||||
|
||||
protected EntityManager createIsolatedEntityManager() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user