HHH-10996 - The cleanupTestData utility has issues with link tables
This commit is contained in:
parent
65fee06bd6
commit
8f5ba32990
|
@ -138,14 +138,6 @@ public class CollectionMapWithComponentValueTest extends BaseCoreFunctionalTestC
|
|||
return true;
|
||||
}
|
||||
|
||||
protected void cleanupTestData() {
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
s.createQuery( "from TestEntity" )
|
||||
.list()
|
||||
.forEach( te -> s.delete( te ) );
|
||||
} );
|
||||
}
|
||||
|
||||
@Entity(name = "TestEntity")
|
||||
@Table(name = "TEST_ENTITY")
|
||||
public static class TestEntity {
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.hibernate.testing.cache.CachingRegionFactory;
|
|||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
|
@ -373,20 +374,11 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
|
|||
}
|
||||
|
||||
protected void cleanupTestData() throws Exception {
|
||||
Session s = openSession();
|
||||
Transaction transaction = s.beginTransaction();
|
||||
try {
|
||||
s.createQuery( "delete from java.lang.Object" ).executeUpdate();
|
||||
transaction.commit();
|
||||
}
|
||||
catch (Exception e) {
|
||||
if ( transaction.getStatus().canRollback() ) {
|
||||
transaction.rollback();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
s.close();
|
||||
}
|
||||
// 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
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
s.createQuery( "from java.lang.Object" ).list().forEach( s::remove );
|
||||
} );
|
||||
}
|
||||
|
||||
private void cleanupSession() {
|
||||
|
|
Loading…
Reference in New Issue