From b57ad86500bfd90076ea549f620015000441247e Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Sat, 25 Jul 2020 15:31:52 +0100 Subject: [PATCH] HHH-13724 Fix failing tests --- .../hibernate/query/hhh14112/HHH14112Test.java | 2 +- .../test/batch/BatchOptimisticLockingTest.java | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/query/hhh14112/HHH14112Test.java b/hibernate-core/src/test/java/org/hibernate/query/hhh14112/HHH14112Test.java index 480be66618..0f9e690530 100644 --- a/hibernate-core/src/test/java/org/hibernate/query/hhh14112/HHH14112Test.java +++ b/hibernate-core/src/test/java/org/hibernate/query/hhh14112/HHH14112Test.java @@ -36,7 +36,7 @@ public class HHH14112Test extends BaseCoreFunctionalTestCase { @Entity(name = "Super") @Inheritance(strategy = InheritanceType.JOINED) - @Where(clause = "DELETED = 0") + @Where(clause = "DELETED = false") public static class Super { @Id @GeneratedValue(strategy = GenerationType.AUTO) diff --git a/hibernate-core/src/test/java/org/hibernate/test/batch/BatchOptimisticLockingTest.java b/hibernate-core/src/test/java/org/hibernate/test/batch/BatchOptimisticLockingTest.java index 124342d23d..98dabc0cbe 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/batch/BatchOptimisticLockingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/batch/BatchOptimisticLockingTest.java @@ -18,6 +18,7 @@ import javax.persistence.OptimisticLockException; import javax.persistence.Version; import org.hibernate.cfg.AvailableSettings; +import org.hibernate.dialect.CockroachDB192Dialect; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; import org.junit.Test; @@ -91,8 +92,21 @@ public class BatchOptimisticLockingTest extends } ); } catch (Exception expected) { - assertEquals( OptimisticLockException.class, expected.getClass()); - assertEquals( "Batch update returned unexpected row count from update [1]; actual row count: 0; expected: 1; statement executed: update Person set name=?, version=? where id=? and version=?", expected.getMessage() ); + assertEquals( OptimisticLockException.class, expected.getClass() ); + if ( getDialect() instanceof CockroachDB192Dialect ) { + // CockroachDB always runs in SERIALIZABLE isolation, and uses SQL state 40001 to indicate + // serialization failure. + assertEquals( + "org.hibernate.exception.LockAcquisitionException: could not execute batch", + expected.getMessage() + ); + } + else { + assertEquals( + "Batch update returned unexpected row count from update [1]; actual row count: 0; expected: 1; statement executed: update Person set name=?, version=? where id=? and version=?", + expected.getMessage() + ); + } } }