avoid EntityManager close() exception through isOpen() check (SPR-7215)

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3401 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Juergen Hoeller
2010-06-08 10:21:05 +00:00
parent 52c6a7a6a4
commit 8fad7f1520
5 changed files with 23 additions and 16 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -42,7 +42,6 @@ import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.jdbc.datasource.DataSourceUtils;
import org.springframework.transaction.support.ResourceHolder;
import org.springframework.transaction.support.ResourceHolderSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.Assert;
@@ -328,7 +327,9 @@ public abstract class EntityManagerFactoryUtils {
if (em != null) {
logger.debug("Closing JPA EntityManager");
try {
em.close();
if (em.isOpen()) {
em.close();
}
}
catch (PersistenceException ex) {
logger.debug("Could not close JPA EntityManager", ex);