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 8e52e83683a..be4b678cc7f 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 @@ -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 { 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... + } } }