diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateJpaDialectTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateJpaDialectTests.java index bdd6e5f62a..1ebb994930 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateJpaDialectTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateJpaDialectTests.java @@ -17,11 +17,11 @@ package org.springframework.orm.jpa.hibernate; import jakarta.persistence.OptimisticLockException; -import jakarta.persistence.PersistenceException; import org.hibernate.HibernateException; import org.hibernate.dialect.lock.OptimisticEntityLockException; import org.junit.jupiter.api.Test; +import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.orm.ObjectOptimisticLockingFailureException; import org.springframework.orm.jpa.JpaDialect; import org.springframework.orm.jpa.JpaOptimisticLockingFailureException; @@ -40,7 +40,7 @@ class HibernateJpaDialectTests { @Test void testTranslateException() { // Plain JPA exception - PersistenceException ex = new OptimisticLockException(); + RuntimeException ex = new OptimisticLockException(); assertThat(dialect.translateExceptionIfPossible(ex)) .isInstanceOf(JpaOptimisticLockingFailureException.class).hasCause(ex); @@ -53,6 +53,11 @@ class HibernateJpaDialectTests { ex = new HibernateException(new OptimisticEntityLockException("", "")); assertThat(dialect.translateExceptionIfPossible(ex)) .isInstanceOf(ObjectOptimisticLockingFailureException.class).hasCause(ex); + + // IllegalArgumentException + ex = new IllegalArgumentException(""); + assertThat(dialect.translateExceptionIfPossible(ex)) + .isInstanceOf(InvalidDataAccessApiUsageException.class).hasCause(ex); } }