/** * Obtain a new EntityManager from this accessor's EntityManagerFactory. * <p>Can be overridden in subclasses to create specific EntityManager variants. * @return a new EntityManager * @throws IllegalStateException if this accessor is not configured with an EntityManagerFactory * @see javax.persistence.EntityManagerFactory#createEntityManager() * @see javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map) */ protected EntityManager createEntityManager() throws IllegalStateException { EntityManagerFactory emf = obtainEntityManagerFactory(); Map<String, Object> properties = getJpaPropertyMap(); return (!CollectionUtils.isEmpty(properties) ? emf.createEntityManager(properties) : emf.createEntityManager()); }
/** * Obtain the transactional EntityManager for this accessor's EntityManagerFactory, if any. * @return the transactional EntityManager, or {@code null} if none * @throws IllegalStateException if this accessor is not configured with an EntityManagerFactory * @see EntityManagerFactoryUtils#getTransactionalEntityManager(javax.persistence.EntityManagerFactory) * @see EntityManagerFactoryUtils#getTransactionalEntityManager(javax.persistence.EntityManagerFactory, java.util.Map) */ @Nullable protected EntityManager getTransactionalEntityManager() throws IllegalStateException{ EntityManagerFactory emf = obtainEntityManagerFactory(); return EntityManagerFactoryUtils.getTransactionalEntityManager(emf, getJpaPropertyMap()); }
/** * Obtain a new EntityManager from this accessor's EntityManagerFactory. * <p>Can be overridden in subclasses to create specific EntityManager variants. * @return a new EntityManager * @throws IllegalStateException if this accessor is not configured with an EntityManagerFactory * @see javax.persistence.EntityManagerFactory#createEntityManager() * @see javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map) */ protected EntityManager createEntityManager() throws IllegalStateException { EntityManagerFactory emf = obtainEntityManagerFactory(); Map<String, Object> properties = getJpaPropertyMap(); return (!CollectionUtils.isEmpty(properties) ? emf.createEntityManager(properties) : emf.createEntityManager()); }
/** * Obtain the transactional EntityManager for this accessor's EntityManagerFactory, if any. * @return the transactional EntityManager, or {@code null} if none * @throws IllegalStateException if this accessor is not configured with an EntityManagerFactory * @see EntityManagerFactoryUtils#getTransactionalEntityManager(javax.persistence.EntityManagerFactory) * @see EntityManagerFactoryUtils#getTransactionalEntityManager(javax.persistence.EntityManagerFactory, java.util.Map) */ @Nullable protected EntityManager getTransactionalEntityManager() throws IllegalStateException{ EntityManagerFactory emf = obtainEntityManagerFactory(); return EntityManagerFactoryUtils.getTransactionalEntityManager(emf, getJpaPropertyMap()); }