HHH-11740 - Default MultiTableBulkIdStrategy for DB2 does not work with connection pools

- Fix tests on PostgreSQL
This commit is contained in:
Vlad Mihalcea 2017-05-15 17:55:22 +03:00
parent 6a0a6d7562
commit 386b04872f
1 changed files with 39 additions and 49 deletions

View File

@ -22,6 +22,7 @@ import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@ -414,9 +415,7 @@ public class UnionSubclassTest extends BaseCoreFunctionalTestCase {
comment = "skip dialects that throw PessimisticLockException"
)
public void testBulkOperationsInTwoConcurrentSessions() throws Exception {
Session s = openSession();
s.getTransaction().begin();
doInHibernate( this::sessionFactory, s -> {
Location mars = new Location( "Mars" );
s.persist( mars );
@ -438,40 +437,31 @@ public class UnionSubclassTest extends BaseCoreFunctionalTestCase {
Human human = new Human();
human.setIdentity( "Jane Doe" );
human.setSex( 'M' );
earth.addBeing( human );
s.persist( human );
} );
s.getTransaction().commit();
s.close();
Session s1 = openSession();
s1.beginTransaction();
doInHibernate( this::sessionFactory, s1 -> {
assertEquals(
1,
s1.createQuery( "update Being set identity = 'John Doe' where identity = 'Jane Doe'" )
.executeUpdate()
);
Session s2 = openSession();
s2.beginTransaction();
doInHibernate( this::sessionFactory, s2 -> {
assertEquals( 1, s2.createQuery( "delete from Being where species = 'Martian'" ).executeUpdate() );
} );
} );
s2.getTransaction().commit();
s1.getTransaction().commit();
s1.close();
s2.close();
s = openSession();
s.getTransaction().begin();
human = (Human) s.createQuery( "from Being" ).uniqueResult();
doInHibernate( this::sessionFactory, s -> {
Human human = (Human) s.createQuery( "from Being" ).uniqueResult();
assertEquals( "John Doe", human.getIdentity() );
s.createQuery( "delete from Being" ).executeUpdate();
s.createQuery( "delete from Hive" ).executeUpdate();
s.createQuery( "delete from Location" ).executeUpdate();
s.getTransaction().commit();
s.close();
} );
}
}