17
17
package org .springframework .orm .jpa .hibernate ;
18
18
19
19
import jakarta .persistence .OptimisticLockException ;
20
- import jakarta .persistence .PersistenceException ;
21
20
import org .hibernate .HibernateException ;
22
21
import org .hibernate .dialect .lock .OptimisticEntityLockException ;
23
22
import org .junit .jupiter .api .Test ;
24
23
24
+ import org .springframework .dao .InvalidDataAccessApiUsageException ;
25
25
import org .springframework .orm .ObjectOptimisticLockingFailureException ;
26
26
import org .springframework .orm .jpa .JpaDialect ;
27
27
import org .springframework .orm .jpa .JpaOptimisticLockingFailureException ;
@@ -40,7 +40,7 @@ class HibernateJpaDialectTests {
40
40
@ Test
41
41
void testTranslateException () {
42
42
// Plain JPA exception
43
- PersistenceException ex = new OptimisticLockException ();
43
+ RuntimeException ex = new OptimisticLockException ();
44
44
assertThat (dialect .translateExceptionIfPossible (ex ))
45
45
.isInstanceOf (JpaOptimisticLockingFailureException .class ).hasCause (ex );
46
46
@@ -53,6 +53,11 @@ void testTranslateException() {
53
53
ex = new HibernateException (new OptimisticEntityLockException ("" , "" ));
54
54
assertThat (dialect .translateExceptionIfPossible (ex ))
55
55
.isInstanceOf (ObjectOptimisticLockingFailureException .class ).hasCause (ex );
56
+
57
+ // IllegalArgumentException
58
+ ex = new IllegalArgumentException ("" );
59
+ assertThat (dialect .translateExceptionIfPossible (ex ))
60
+ .isInstanceOf (InvalidDataAccessApiUsageException .class ).hasCause (ex );
56
61
}
57
62
58
63
}
0 commit comments