HHH-10996 : Fix to work pre-5.2
This commit is contained in:
parent
fc4665707d
commit
2bf9cadef3
|
@ -36,7 +36,6 @@ import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||||
import org.hibernate.jdbc.AbstractReturningWork;
|
import org.hibernate.jdbc.AbstractReturningWork;
|
||||||
import org.hibernate.jdbc.Work;
|
import org.hibernate.jdbc.Work;
|
||||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
|
||||||
|
|
||||||
import org.hibernate.testing.AfterClassOnce;
|
import org.hibernate.testing.AfterClassOnce;
|
||||||
import org.hibernate.testing.BeforeClassOnce;
|
import org.hibernate.testing.BeforeClassOnce;
|
||||||
|
@ -47,7 +46,6 @@ import org.hibernate.testing.cache.CachingRegionFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -377,9 +375,22 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
|
||||||
protected void cleanupTestData() throws Exception {
|
protected void cleanupTestData() throws Exception {
|
||||||
// Because of https://hibernate.atlassian.net/browse/HHH-5529,
|
// Because of https://hibernate.atlassian.net/browse/HHH-5529,
|
||||||
// we can'trely on a Bulk Delete query which will not clear the link tables in @ElementCollection or unidirectional collections
|
// we can'trely on a Bulk Delete query which will not clear the link tables in @ElementCollection or unidirectional collections
|
||||||
doInHibernate( this::sessionFactory, s -> {
|
Session s = openSession();
|
||||||
s.createQuery( "from java.lang.Object" ).list().forEach( s::remove );
|
Transaction transaction = s.beginTransaction();
|
||||||
} );
|
s.getTransaction().begin();
|
||||||
|
try {
|
||||||
|
for ( Object o : s.createQuery( "from java.lang.Object" ).list() ) {
|
||||||
|
s.delete( o );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
if ( transaction.getStatus().canRollback() ) {
|
||||||
|
transaction.rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
s.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupSession() {
|
private void cleanupSession() {
|
||||||
|
|
Loading…
Reference in New Issue