Skip to content

Commit 511739e

Browse files
committed
Add missing test for IllegalArgumentException
See gh-35111
1 parent 61474cc commit 511739e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateJpaDialectTests.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
package org.springframework.orm.jpa.hibernate;
1818

1919
import jakarta.persistence.OptimisticLockException;
20-
import jakarta.persistence.PersistenceException;
2120
import org.hibernate.HibernateException;
2221
import org.hibernate.dialect.lock.OptimisticEntityLockException;
2322
import org.junit.jupiter.api.Test;
2423

24+
import org.springframework.dao.InvalidDataAccessApiUsageException;
2525
import org.springframework.orm.ObjectOptimisticLockingFailureException;
2626
import org.springframework.orm.jpa.JpaDialect;
2727
import org.springframework.orm.jpa.JpaOptimisticLockingFailureException;
@@ -40,7 +40,7 @@ class HibernateJpaDialectTests {
4040
@Test
4141
void testTranslateException() {
4242
// Plain JPA exception
43-
PersistenceException ex = new OptimisticLockException();
43+
RuntimeException ex = new OptimisticLockException();
4444
assertThat(dialect.translateExceptionIfPossible(ex))
4545
.isInstanceOf(JpaOptimisticLockingFailureException.class).hasCause(ex);
4646

@@ -53,6 +53,11 @@ void testTranslateException() {
5353
ex = new HibernateException(new OptimisticEntityLockException("", ""));
5454
assertThat(dialect.translateExceptionIfPossible(ex))
5555
.isInstanceOf(ObjectOptimisticLockingFailureException.class).hasCause(ex);
56+
57+
// IllegalArgumentException
58+
ex = new IllegalArgumentException("");
59+
assertThat(dialect.translateExceptionIfPossible(ex))
60+
.isInstanceOf(InvalidDataAccessApiUsageException.class).hasCause(ex);
5661
}
5762

5863
}

0 commit comments

Comments
 (0)