OpenEntityManagerInViewFilter.java 文件源码

java
阅读 35 收藏 0 点赞 0 评论 0

项目:lams 作者:
/**
 * Look up the EntityManagerFactory that this filter should use.
 * <p>The default implementation looks for a bean with the specified name
 * in Spring's root application context.
 * @return the EntityManagerFactory to use
 * @see #getEntityManagerFactoryBeanName
 */
protected EntityManagerFactory lookupEntityManagerFactory() {
    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
    String emfBeanName = getEntityManagerFactoryBeanName();
    String puName = getPersistenceUnitName();
    if (StringUtils.hasLength(emfBeanName)) {
        return wac.getBean(emfBeanName, EntityManagerFactory.class);
    }
    else if (!StringUtils.hasLength(puName) && wac.containsBean(DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME)) {
        return wac.getBean(DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME, EntityManagerFactory.class);
    }
    else {
        // Includes fallback search for single EntityManagerFactory bean by type.
        return EntityManagerFactoryUtils.findEntityManagerFactory(wac, puName);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号