/** * Return interface providing access to utility methods for the persistence * unit. * * @return PersistenceUnitUtil interface * @throws IllegalStateException * if the entity manager factory has been closed * @see javax.persistence.EntityManagerFactory#getPersistenceUnitUtil() */ @Override public PersistenceUnitUtil getPersistenceUnitUtil() { if (!isOpen()) { throw new IllegalStateException("Entity manager factory has been closed."); } return this.util; }
/** * Get the properties and associated values that are in effect for the * entity manager factory. Changing the contents of the map does not change * the configuration in effect. * * @return properties * @throws IllegalStateException * if the entity manager factory has been closed * @see javax.persistence.EntityManagerFactory#getProperties() */ @Override public Map<String, Object> getProperties() { if (isOpen()) { return properties; } throw new IllegalStateException("Entity manager factory has been closed."); }
/** * Return an instance of CriteriaBuilder for the creation of CriteriaQuery * objects. * * @return CriteriaBuilder instance * @throws IllegalStateException * if the entity manager factory has been closed * @see javax.persistence.EntityManagerFactory#getCriteriaBuilder() */ @Override public CriteriaBuilder getCriteriaBuilder() { if (isOpen()) { return new KunderaCriteriaBuilder(this); } throw new IllegalStateException("Entity manager factory has been closed."); }
/** * Create a new application-managed EntityManager. This method returns a new * EntityManager instance each time it is invoked. The isOpen method will * return true on the returned instance. * * @return entity manager instance * @throws IllegalStateException * if the entity manager factory has been closed */ @Override public final EntityManager createEntityManager() { // For Application managed persistence context, type is always EXTENDED if (isOpen()) { return new EntityManagerImpl(this, transactionType, PersistenceContextType.EXTENDED); } throw new IllegalStateException("Entity manager factory has been closed."); }
/** * Access the cache that is associated with the entity manager factory (the * "second level cache"). * * @return instance of the Cache interface * @throws IllegalStateException * if the entity manager factory has been closed * @see javax.persistence.EntityManagerFactory#getCache() */ @Override public Cache getCache() { if (isOpen()) { return cacheProvider.getCache(Constants.KUNDERA_SECONDARY_CACHE_NAME); } throw new IllegalStateException("Entity manager factory has been closed."); }
/** * Create a new application-managed EntityManager with the specified Map of * properties. This method returns a new EntityManager instance each time it * is invoked. The isOpen method will return true on the returned instance. * * @param map * properties for entity manager * @return entity manager instance * @throws IllegalStateException * if the entity manager factory has been closed */ @Override public final EntityManager createEntityManager(Map map) { // For Application managed persistence context, type is always EXTENDED if (isOpen()) { return new EntityManagerImpl(this, map, transactionType, PersistenceContextType.EXTENDED); } throw new IllegalStateException("Entity manager factory has been closed."); }
public final void close() if (isOpen())
/** * Return an instance of Metamodel interface for access to the metamodel of * the persistence unit. * * @return Metamodel instance * @throws IllegalStateException * if the entity manager factory has been closed * @see javax.persistence.EntityManagerFactory#getMetamodel() */ @Override public Metamodel getMetamodel() { if (isOpen()) { MetamodelImpl metamodel = null; for (String pu : persistenceUnits) { metamodel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(pu); if (metamodel != null) { return metamodel; } } // return // KunderaMetadataManager.getMetamodel(getPersistenceUnits()); } throw new IllegalStateException("Entity manager factory has been closed."); }