Browse Source

JPA EntityManagerFactoryUtils silently ignores IllegalArgumentExceptions from setHint calls (SPR-7947)

pull/7/head
Juergen Hoeller 13 years ago
parent
commit
2cb287a01b
  1. 14
      org.springframework.orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java

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

@ -263,8 +263,18 @@ public abstract class EntityManagerFactoryUtils { @@ -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...
}
}
}

Loading…
Cancel
Save