Search in sources :

Example 1 with EJB3ConfigurationDao

use of org.broadleafcommerce.common.util.dao.EJB3ConfigurationDao in project BroadleafCommerce by BroadleafCommerce.

the class PersistenceManagerImpl method configureDefaultDynamicEntityDao.

@Override
public void configureDefaultDynamicEntityDao(TargetModeType targetModeType) {
    EntityManager entityManager = getDefaultEntityManager(targetModeType);
    dynamicEntityDao.setStandardEntityManager(entityManager);
    EJB3ConfigurationDao ejb3ConfigurationDao = getDefaultEJB3ConfigurationDao(targetModeType);
    dynamicEntityDao.setEjb3ConfigurationDao(ejb3ConfigurationDao);
}
Also used : EntityManager(javax.persistence.EntityManager) EJB3ConfigurationDao(org.broadleafcommerce.common.util.dao.EJB3ConfigurationDao)

Example 2 with EJB3ConfigurationDao

use of org.broadleafcommerce.common.util.dao.EJB3ConfigurationDao in project BroadleafCommerce by BroadleafCommerce.

the class PersistenceManagerImpl method configureDynamicEntityDao.

@Override
public void configureDynamicEntityDao(Class entityClass, TargetModeType targetModeType) {
    EntityManager entityManager = getEntityManager(entityClass, targetModeType);
    dynamicEntityDao.setStandardEntityManager(entityManager);
    EJB3ConfigurationDao ejb3ConfigurationDao = getEJB3ConfigurationDao(entityClass);
    dynamicEntityDao.setEjb3ConfigurationDao(ejb3ConfigurationDao);
}
Also used : EntityManager(javax.persistence.EntityManager) EJB3ConfigurationDao(org.broadleafcommerce.common.util.dao.EJB3ConfigurationDao)

Example 3 with EJB3ConfigurationDao

use of org.broadleafcommerce.common.util.dao.EJB3ConfigurationDao in project BroadleafCommerce by BroadleafCommerce.

the class PersistenceServiceImpl method populateCaches.

protected void populateCaches(String targetMode, Map<String, Object> managerMap) {
    final EntityManager em = getEntityManager(managerMap);
    final PlatformTransactionManager txManager = getTransactionManager(managerMap);
    final EJB3ConfigurationDao ejb3ConfigurationDao = getEJB3ConfigurationDao(managerMap);
    SessionFactory sessionFactory = em.unwrap(Session.class).getSessionFactory();
    for (Object item : sessionFactory.getAllClassMetadata().values()) {
        ClassMetadata metadata = (ClassMetadata) item;
        Class<?> mappedClass = metadata.getMappedClass();
        String managerCacheKey = buildManagerCacheKey(targetMode, mappedClass);
        ENTITY_MANAGER_CACHE.put(managerCacheKey, em);
        TRANSACTION_MANAGER_CACHE.put(managerCacheKey, txManager);
        String ejb3ConfigDaoCacheKey = buildEJB3ConfigDaoCacheKey(mappedClass);
        if (!EJB3_CONFIG_DAO_CACHE.containsKey(ejb3ConfigDaoCacheKey)) {
            EJB3_CONFIG_DAO_CACHE.put(ejb3ConfigDaoCacheKey, ejb3ConfigurationDao);
        }
    }
}
Also used : SessionFactory(org.hibernate.SessionFactory) ClassMetadata(org.hibernate.metadata.ClassMetadata) EntityManager(javax.persistence.EntityManager) EJB3ConfigurationDao(org.broadleafcommerce.common.util.dao.EJB3ConfigurationDao) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) Session(org.hibernate.Session)

Example 4 with EJB3ConfigurationDao

use of org.broadleafcommerce.common.util.dao.EJB3ConfigurationDao in project BroadleafCommerce by BroadleafCommerce.

the class PersistenceServiceImpl method identifyEJB3ConfigurationDao.

@Override
public EJB3ConfigurationDao identifyEJB3ConfigurationDao(Class entityClass) {
    String cacheKey = buildEJB3ConfigDaoCacheKey(entityClass);
    EJB3ConfigurationDao ejb3ConfigurationDao = EJB3_CONFIG_DAO_CACHE.get(cacheKey);
    if (ejb3ConfigurationDao == null) {
        throw new RuntimeException("Unable to determine the EJB3ConfigurationDao for the following class: " + entityClass.getName());
    }
    return ejb3ConfigurationDao;
}
Also used : EJB3ConfigurationDao(org.broadleafcommerce.common.util.dao.EJB3ConfigurationDao)

Aggregations

EJB3ConfigurationDao (org.broadleafcommerce.common.util.dao.EJB3ConfigurationDao)4 EntityManager (javax.persistence.EntityManager)3 Session (org.hibernate.Session)1 SessionFactory (org.hibernate.SessionFactory)1 ClassMetadata (org.hibernate.metadata.ClassMetadata)1 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)1