From c6dc398fc51fd897c156e381ad1fd6d3304d7530 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Fri, 27 Apr 2018 09:41:44 -0500 Subject: [PATCH] HHH-8786 - find, refresh, lock should throw LockTimeoutException or PessimisticLockException when lock problems occur --- .../org/hibernate/test/jpa/lock/LockExceptionTests.java | 6 ++++++ .../src/test/java/org/hibernate/test/legacy/FooBarTest.java | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/jpa/lock/LockExceptionTests.java b/hibernate-core/src/test/java/org/hibernate/test/jpa/lock/LockExceptionTests.java index 1857eef99a..01020dec39 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/jpa/lock/LockExceptionTests.java +++ b/hibernate-core/src/test/java/org/hibernate/test/jpa/lock/LockExceptionTests.java @@ -14,8 +14,11 @@ import javax.persistence.PessimisticLockException; import org.hibernate.LockOptions; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; +import org.hibernate.dialect.MariaDBDialect; import org.hibernate.dialect.SQLServerDialect; +import org.hibernate.testing.SkipForDialect; +import org.hibernate.testing.SkipForDialects; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.jdbc.SQLServerSnapshotIsolationConnectionProvider; import org.hibernate.testing.transaction.TransactionUtil2; @@ -28,6 +31,9 @@ import static org.junit.Assert.fail; /** * @author Steve Ebersole */ +@SkipForDialects( + @SkipForDialect( value = MariaDBDialect.class, jiraKey = "HHH-8786", comment = "https://hibernate.atlassian.net/browse/HHH-8786") +) public class LockExceptionTests extends AbstractJPATest { @Override public void configure(Configuration cfg) { diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java b/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java index dcba68dd22..3c9ba5db95 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java @@ -4330,7 +4330,10 @@ public class FooBarTest extends LegacyTestCase { ); s.refresh(foo); assertEquals( Long.valueOf( -3l ), foo.getLong() ); - assertEquals( LockMode.READ, s.getCurrentLockMode( foo ) ); + // NOTE : this test used to test for LockMode.READ here, but that actually highlights a bug + // `foo` has just been inserted and then updated in this same Session - its lock mode + // therefore ought to be WRITE. See https://hibernate.atlassian.net/browse/HHH-12257 + assertEquals( LockMode.WRITE, s.getCurrentLockMode( foo ) ); s.refresh(foo, LockMode.UPGRADE); if ( getDialect().supportsOuterJoinForUpdate() ) { assertEquals( LockMode.UPGRADE, s.getCurrentLockMode( foo ) );