From 2cb287a01b0190acac7bcdc0af8835227adada5d Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 28 Nov 2011 20:54:37 +0000 Subject: [PATCH] JPA EntityManagerFactoryUtils silently ignores IllegalArgumentExceptions from setHint calls (SPR-7947) --- .../orm/jpa/EntityManagerFactoryUtils.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/org.springframework.orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java b/org.springframework.orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java index 8e5fc87af5..9196b8dee4 100644 --- a/org.springframework.orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java +++ b/org.springframework.orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java @@ -263,8 +263,18 @@ public abstract class EntityManagerFactoryUtils { EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource(emf); if (emHolder != null && emHolder.hasTimeout()) { int timeoutValue = (int) emHolder.getTimeToLiveInMillis(); - query.setHint("javax.persistence.lock.timeout", timeoutValue); - query.setHint("javax.persistence.query.timeout", timeoutValue); + try { + query.setHint("javax.persistence.lock.timeout", timeoutValue); + } + catch (IllegalArgumentException ex) { + // oh well, at least we tried... + } + try { + query.setHint("javax.persistence.query.timeout", timeoutValue); + } + catch (IllegalArgumentException ex) { + // once again, at least we tried... + } } }