Browse Source

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

3.0.x
Juergen Hoeller 14 years ago
parent
commit
c6b36cc207
  1. 16
      org.springframework.orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -258,8 +258,18 @@ public abstract class EntityManagerFactoryUtils { @@ -258,8 +258,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