diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java index f51e2833ce..2094e5abaa 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java @@ -17,6 +17,7 @@ import java.util.List; import java.util.TimeZone; import org.hibernate.PessimisticLockException; +import org.hibernate.QueryTimeoutException; import org.hibernate.boot.model.FunctionContributions; import org.hibernate.boot.model.TypeContributions; import org.hibernate.dialect.DatabaseVersion; @@ -759,6 +760,8 @@ public class H2LegacyDialect extends Dialect { // NULL not allowed for column [90006-145] final String constraintName = getViolatedConstraintNameExtractor().extractConstraintName(sqlException); return new ConstraintViolationException(message, sqlException, sql, constraintName); + case 57014: + return new QueryTimeoutException( message, sqlException, sql ); } return null; diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java index c8ac546e60..449d862d58 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java @@ -17,6 +17,7 @@ import java.util.List; import java.util.TimeZone; import org.hibernate.PessimisticLockException; +import org.hibernate.QueryTimeoutException; import org.hibernate.boot.model.FunctionContributions; import org.hibernate.boot.model.TypeContributions; import org.hibernate.dialect.function.CommonFunctionFactory; @@ -753,6 +754,8 @@ public class H2Dialect extends Dialect { // NULL not allowed for column [90006-145] final String constraintName = getViolatedConstraintNameExtractor().extractConstraintName(sqlException); return new ConstraintViolationException(message, sqlException, sql, constraintName); + case 57014: + return new QueryTimeoutException( message, sqlException, sql ); } return null; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/locking/jpa/FollowOnLockingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/locking/jpa/FollowOnLockingTest.java index 9d8184f828..b4c0912a10 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/locking/jpa/FollowOnLockingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/locking/jpa/FollowOnLockingTest.java @@ -9,6 +9,7 @@ package org.hibernate.orm.test.locking.jpa; import java.util.List; import java.util.Map; +import org.hibernate.dialect.CockroachDialect; import org.hibernate.dialect.HSQLDialect; import org.hibernate.query.spi.QueryImplementor; @@ -35,6 +36,7 @@ import static org.hibernate.jpa.SpecHints.HINT_SPEC_QUERY_TIMEOUT; @DomainModel(annotatedClasses = { Employee.class, Department.class }) @SessionFactory(useCollectingStatementInspector = true) @SkipForDialect(dialectClass = HSQLDialect.class, reason = "Seems HSQLDB doesn't cancel the query if it waits for a lock?!") +@SkipForDialect(dialectClass = CockroachDialect.class, reason = "Cockroach allows the concurrent access but cancels one or both transactions at the end") public class FollowOnLockingTest { @Test