Skip to content

Commit

Permalink
Handle timeout exception for older H2 versions and igonre a test for …
Browse files Browse the repository at this point in the history
…Cockroach
  • Loading branch information
beikov committed Jun 26, 2023
1 parent d16808e commit a098abf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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.*;
Expand Down Expand Up @@ -752,6 +753,8 @@ public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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;
Expand Down Expand Up @@ -758,6 +759,8 @@ public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.List;
import java.util.Map;

import org.hibernate.dialect.CockroachDialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.query.spi.QueryImplementor;

Expand All @@ -35,6 +36,7 @@
@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
Expand Down

0 comments on commit a098abf

Please sign in to comment.