Skip to content

Commit 2cb287a

Browse files
committed
JPA EntityManagerFactoryUtils silently ignores IllegalArgumentExceptions from setHint calls (SPR-7947)
1 parent e627231 commit 2cb287a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

org.springframework.orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,18 @@ public static void applyTransactionTimeout(Query query, EntityManagerFactory emf
263263
EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource(emf);
264264
if (emHolder != null && emHolder.hasTimeout()) {
265265
int timeoutValue = (int) emHolder.getTimeToLiveInMillis();
266-
query.setHint("javax.persistence.lock.timeout", timeoutValue);
267-
query.setHint("javax.persistence.query.timeout", timeoutValue);
266+
try {
267+
query.setHint("javax.persistence.lock.timeout", timeoutValue);
268+
}
269+
catch (IllegalArgumentException ex) {
270+
// oh well, at least we tried...
271+
}
272+
try {
273+
query.setHint("javax.persistence.query.timeout", timeoutValue);
274+
}
275+
catch (IllegalArgumentException ex) {
276+
// once again, at least we tried...
277+
}
268278
}
269279
}
270280

0 commit comments

Comments
 (0)