From 511739e3de44e7f5268b345a9d311a815c1181a6 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 25 Jun 2025 22:35:26 +0200 Subject: [PATCH] Add missing test for IllegalArgumentException See gh-35111 --- .../orm/jpa/hibernate/HibernateJpaDialectTests.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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); } }