From 184361a096f6712115b2c68dd96bbf235a21375f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 4 Dec 2012 15:34:09 +0100 Subject: [PATCH] Transaction timeouts for JPA translate to "javax.persistence.query.timeout" only (for EclipseLink compatibility) Issue: SPR-10068 --- .../orm/jpa/EntityManagerFactoryUtils.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java b/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java index 02963e2fda0..8ed9ed0718f 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java @@ -254,8 +254,7 @@ public abstract class EntityManagerFactoryUtils { /** * Apply the current transaction timeout, if any, to the given JPA Query object. - *

This method sets the JPA 2.0 query hints "javax.persistence.lock.timeout" - * and "javax.persistence.query.timeout" accordingly. + *

This method sets the JPA 2.0 query hint "javax.persistence.query.timeout" accordingly. * @param query the JPA Query object * @param emf JPA EntityManagerFactory that the Query was created for */ @@ -263,17 +262,11 @@ public abstract class EntityManagerFactoryUtils { EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource(emf); if (emHolder != null && emHolder.hasTimeout()) { int timeoutValue = (int) emHolder.getTimeToLiveInMillis(); - 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... + // oh well, at least we tried... } } } @@ -283,11 +276,10 @@ public abstract class EntityManagerFactoryUtils { * org.springframework.dao hierarchy. * Return null if no translation is appropriate: any other exception may * have resulted from user code, and should not be translated. - *

The most important cases like object not found or optimistic locking - * failure are covered here. For more fine-granular conversion, JpaAccessor and - * JpaTransactionManager support sophisticated translation of exceptions via a - * JpaDialect. - * @param ex runtime exception that occured + *

The most important cases like object not found or optimistic locking failure + * are covered here. For more fine-granular conversion, JpaTransactionManager etc + * support sophisticated translation of exceptions via a JpaDialect. + * @param ex runtime exception that occurred * @return the corresponding DataAccessException instance, * or null if the exception should not be translated */