本文整理汇总了Java中org.springframework.orm.jpa.EntityManagerFactoryUtils.closeEntityManager方法的典型用法代码示例。如果您正苦于以下问题:Java EntityManagerFactoryUtils.closeEntityManager方法的具体用法?Java EntityManagerFactoryUtils.closeEntityManager怎么用?Java EntityManagerFactoryUtils.closeEntityManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.orm.jpa.EntityManagerFactoryUtils
的用法示例。
在下文中一共展示了EntityManagerFactoryUtils.closeEntityManager方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterCompletion
import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
@Override
public void afterCompletion(WebRequest request, Exception ex) throws DataAccessException {
if (!decrementParticipateCount(request)) {
EntityManagerHolder emHolder = (EntityManagerHolder)
TransactionSynchronizationManager.unbindResource(getEntityManagerFactory());
logger.debug("Closing JPA EntityManager in OpenEntityManagerInViewInterceptor");
EntityManagerFactoryUtils.closeEntityManager(emHolder.getEntityManager());
}
}
示例2: closeEntityManager
import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
/**
* close the entity manager.
* Use it with caution! This is only intended for use with async request, which Spring won't
* close the entity manager until the async request is finished.
*/
public void closeEntityManager() {
EntityManagerHolder emHolder = (EntityManagerHolder)
TransactionSynchronizationManager.getResource(getEntityManagerFactory());
if (emHolder == null) {
return;
}
logger.debug("Closing JPA EntityManager in EntityManagerUtil");
EntityManagerFactoryUtils.closeEntityManager(emHolder.getEntityManager());
}
示例3: closeEntityManager
import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
/**
* Suppression du EntityManager.
*/
public void closeEntityManager() {
if (TransactionSynchronizationManager.hasResource(entityManagerFactory)) {
EntityManagerHolder entityManagerHolder = (EntityManagerHolder) TransactionSynchronizationManager.unbindResource(entityManagerFactory);
EntityManagerFactoryUtils.closeEntityManager(entityManagerHolder.getEntityManager());
}
}
示例4: afterCompletion
import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
public void afterCompletion(WebRequest request, Exception ex) throws DataAccessException {
if (!decrementParticipateCount(request)) {
EntityManagerHolder emHolder = (EntityManagerHolder)
TransactionSynchronizationManager.unbindResource(getEntityManagerFactory());
logger.debug("Closing JPA EntityManager in OpenEntityManagerInViewInterceptor");
EntityManagerFactoryUtils.closeEntityManager(emHolder.getEntityManager());
}
}
示例5: execute
import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
@Override
public void execute() throws Exception {
EntityManager em = emf.createEntityManager();
EntityManagerHolder emHolder = new EntityManagerHolder(em);
try {
TransactionSynchronizationManager.bindResource(emf, emHolder);
super.execute();
} finally {
EntityManagerHolder emHolderB = (EntityManagerHolder)
TransactionSynchronizationManager.unbindResource(emf);
log.debug("Closing JPA EntityManager in OpenEntityManagerInViewFilter");
EntityManagerFactoryUtils.closeEntityManager(emHolderB.getEntityManager());
}
sleep(DateTry.Second*10);
}
示例6: postProcessBeforeDestruction
import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
@Override
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
EntityManager emToClose = this.extendedEntityManagersToClose.remove(bean);
EntityManagerFactoryUtils.closeEntityManager(emToClose);
}
示例7: closeAfterTimeout
import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
private void closeAfterTimeout() {
if (this.timeoutInProgress) {
logger.debug("Closing JPA EntityManager after async request timeout");
EntityManagerFactoryUtils.closeEntityManager(emHolder.getEntityManager());
}
}
示例8: postProcessBeforeDestruction
import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
EntityManager emToClose = this.extendedEntityManagersToClose.remove(bean);
EntityManagerFactoryUtils.closeEntityManager(emToClose);
}