HHH-10996 - The cleanupTestData utility has issues with link tables
Use bulk delete in certain situations like when we have a @Formula annotation that takes an SQL function which is not supported by the currently running DB
This commit is contained in:
parent
714ba62158
commit
bf823d440c
|
@ -52,10 +52,17 @@ import static org.junit.Assert.fail;
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
public class QueryAndSQLTest extends BaseCoreFunctionalTestCase {
|
public class QueryAndSQLTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isCleanupTestDataRequired() {
|
protected boolean isCleanupTestDataRequired() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isCleanupTestDataUsingBulkDelete() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNativeQueryWithFormulaAttribute() {
|
public void testNativeQueryWithFormulaAttribute() {
|
||||||
SQLFunction dateFunction = getDialect().getFunctions().get( "current_date" );
|
SQLFunction dateFunction = getDialect().getFunctions().get( "current_date" );
|
||||||
|
|
|
@ -373,12 +373,22 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isCleanupTestDataUsingBulkDelete() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected void cleanupTestData() throws Exception {
|
protected void cleanupTestData() throws Exception {
|
||||||
// Because of https://hibernate.atlassian.net/browse/HHH-5529,
|
if(isCleanupTestDataUsingBulkDelete()) {
|
||||||
// we can'trely on a Bulk Delete query which will not clear the link tables in @ElementCollection or unidirectional collections
|
doInHibernate( this::sessionFactory, s -> {
|
||||||
doInHibernate( this::sessionFactory, s -> {
|
s.createQuery( "delete from java.lang.Object" ).executeUpdate();
|
||||||
s.createQuery( "from java.lang.Object" ).list().forEach( s::remove );
|
} );
|
||||||
} );
|
} else {
|
||||||
|
// 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() {
|
private void cleanupSession() {
|
||||||
|
|
Loading…
Reference in New Issue