Class JPAContainerFactory
java.lang.Object
com.vaadin.featurepack.data.jpacontainer.JPAContainerFactory
A factory for creating instances of JPAContainers backed by different default
entity providers.
- Author:
- Jonatan Kronqvist / Vaadin Ltd
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic jakarta.persistence.EntityManagerCreates anEntityManagerusing the cachedEntityManagerFactoryfor the persistence unit.static <T> JPAContainer<T> Creates a new instance of JPAContainer backed by aCachingMutableLocalEntityProvider.static <T> JPAContainer<T> Creates a new instance of a JPAContainer backed by aCachingMutableLocalEntityProvider.static <T> JPAContainer<T> makeBatchable(Class<T> entityClass, jakarta.persistence.EntityManager entityManager) Creates a new instance of JPAContainer backed by aCachingBatchableLocalEntityProvider.static <T> JPAContainer<T> makeBatchable(Class<T> entityClass, String persistenceUnitName) Creates a new instance of JPAContainer backed by aCachingBatchableLocalEntityProvider.static <T> JPAContainer<T> makeBatchableJndi(Class<T> entityClass) Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em".static <T> JPAContainer<T> makeBatchableJndi(Class<T> entityClass, JndiAddresses jndiAddresses) Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em".static <T> JPAContainer<T> Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em".static <T> JPAContainer<T> makeJndi(Class<T> entityClass, JndiAddresses jndiAddresses) Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em".static <T> JPAContainer<T> makeNonCached(Class<T> entityClass, jakarta.persistence.EntityManager entityManager) Creates a new instance of JPAContainer backed by aMutableLocalEntityProvider.static <T> JPAContainer<T> makeNonCached(Class<T> entityClass, String persistenceUnitName) Creates a new instance of JPAContainer backed by aMutableLocalEntityProvider.static <T> JPAContainer<T> makeNonCachedJndi(Class<T> entityClass) Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em".static <T> JPAContainer<T> makeNonCachedJndi(Class<T> entityClass, JndiAddresses jndiAddresses) Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em".static <T> JPAContainer<T> makeNonCachedReadOnly(Class<T> entityClass, jakarta.persistence.EntityManager entityManager) Creates a new instance of JPAContainer backed by aLocalEntityProvider.static <T> JPAContainer<T> makeNonCachedReadOnly(Class<T> entityClass, String persistenceUnitName) Creates a new instance of JPAContainer backed by aLocalEntityProvider.static <T> JPAContainer<T> makeNonCachedReadOnlyJndi(Class<T> entityClass) Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em".static <T> JPAContainer<T> makeNonCachedReadOnlyJndi(Class<T> entityClass, JndiAddresses jndiAddresses) Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em".static <T> JPAContainer<T> makeReadOnly(Class<T> entityClass, jakarta.persistence.EntityManager entityManager) Creates a new instance of JPAContainer backed by aCachingLocalEntityProvider.static <T> JPAContainer<T> makeReadOnly(Class<T> entityClass, String persistenceUnitName) Creates a new instance of JPAContainer backed by aCachingLocalEntityProvider.
-
Constructor Details
-
JPAContainerFactory
public JPAContainerFactory()
-
-
Method Details
-
make
public static <T> JPAContainer<T> make(Class<T> entityClass, jakarta.persistence.EntityManager entityManager) Creates a new instance of JPAContainer backed by aCachingMutableLocalEntityProvider. This method should be used if you already know an instance ofEntityManager.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entityentityManager- the entity manager to use- Returns:
- a fully configured JPAContainer instance
-
make
Creates a new instance of a JPAContainer backed by aCachingMutableLocalEntityProvider. This method can be used if you do not know and do not need/want to know the instance ofEntityManagerthat is used, which is the case in simplistic instances. An instance ofEntityManagerFactorywill be created for the persistence unit and used to build entity managers.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entitypersistenceUnitName- the persistency context to use to create entity managers- Returns:
- a fully configured JPAContainer instance
-
createEntityManagerForPersistenceUnit
Creates anEntityManagerusing the cachedEntityManagerFactoryfor the persistence unit. If no entity manager factory exists, one is created before using it to build the entity manager.- Parameters:
name- the name of the persistence unit.- Returns:
- an entity manager for the persistence unit.
-
makeReadOnly
public static <T> JPAContainer<T> makeReadOnly(Class<T> entityClass, jakarta.persistence.EntityManager entityManager) Creates a new instance of JPAContainer backed by aCachingLocalEntityProvider. This method should be used if you already know an instance ofEntityManager.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entityentityManager- the entity manager to use- Returns:
- a fully configured JPAContainer instance
-
makeReadOnly
Creates a new instance of JPAContainer backed by aCachingLocalEntityProvider. This method can be used if you do not know and do not need/want to know the instance ofEntityManagerthat is used, which is the case in simplistic instances. An instance ofEntityManagerFactorywill be created for the persistence unit and used to build entity managers.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entitypersistenceUnitName- the persistency context to use to create entity managers- Returns:
- a fully configured JPAContainer instance
-
makeBatchable
public static <T> JPAContainer<T> makeBatchable(Class<T> entityClass, jakarta.persistence.EntityManager entityManager) Creates a new instance of JPAContainer backed by aCachingBatchableLocalEntityProvider. This method should be used if you already know an instance ofEntityManager.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entityentityManager- the entity manager to use- Returns:
- a fully configured JPAContainer instance
-
makeBatchable
Creates a new instance of JPAContainer backed by aCachingBatchableLocalEntityProvider. This method can be used if you do not know and do not need/want to know the instance ofEntityManagerthat is used, which is the case in simplistic instances. An instance ofEntityManagerFactorywill be created for the persistence unit and used to build entity managers.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entitypersistenceUnitName- the persistency context to use to create entity managers- Returns:
- a fully configured JPAContainer instance
-
makeNonCached
public static <T> JPAContainer<T> makeNonCached(Class<T> entityClass, jakarta.persistence.EntityManager entityManager) Creates a new instance of JPAContainer backed by aMutableLocalEntityProvider. This method should be used if you already know an instance ofEntityManager.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entityentityManager- the entity manager to use- Returns:
- a fully configured JPAContainer instance
-
makeNonCached
Creates a new instance of JPAContainer backed by aMutableLocalEntityProvider. This method can be used if you do not know and do not need/want to know the instance ofEntityManagerthat is used, which is the case in simplistic instances. An instance ofEntityManagerFactorywill be created for the persistence unit and used to build entity managers.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entitypersistenceUnitName- the persistency context to use to create entity managers- Returns:
- a fully configured JPAContainer instance
-
makeNonCachedReadOnly
public static <T> JPAContainer<T> makeNonCachedReadOnly(Class<T> entityClass, jakarta.persistence.EntityManager entityManager) Creates a new instance of JPAContainer backed by aLocalEntityProvider. This method should be used if you already know an instance ofEntityManager.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entityentityManager- the entity manager to use- Returns:
- a fully configured JPAContainer instance
-
makeNonCachedReadOnly
public static <T> JPAContainer<T> makeNonCachedReadOnly(Class<T> entityClass, String persistenceUnitName) Creates a new instance of JPAContainer backed by aLocalEntityProvider. This method can be used if you do not know and do not need/want to know the instance ofEntityManagerthat is used, which is the case in simplistic instances. An instance ofEntityManagerFactorywill be created for the persistence unit and used to build entity managers.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entitypersistenceUnitName- the persistency context to use to create entity managers- Returns:
- a fully configured JPAContainer instance
-
makeNonCachedReadOnlyJndi
Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em". Container also uses JTA transactions. This type of container commonly suits for JEE6 environment.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entity- Returns:
- a fully configured JPAContainer instance
-
makeNonCachedReadOnlyJndi
public static <T> JPAContainer<T> makeNonCachedReadOnlyJndi(Class<T> entityClass, JndiAddresses jndiAddresses) Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em". Container also uses JTA transactions. This type of container commonly suits for JEE6 environment.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entityjndiAddresses- to be used to get references toEntityManagerandUserTransaction- Returns:
- a fully configured JPAContainer instance
-
makeNonCachedJndi
Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em". Container also uses JTA transactions. This type of container commonly suits for JEE6 environment.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entity- Returns:
- a fully configured JPAContainer instance
-
makeNonCachedJndi
public static <T> JPAContainer<T> makeNonCachedJndi(Class<T> entityClass, JndiAddresses jndiAddresses) Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em". Container also uses JTA transactions. This type of container commonly suits for JEE6 environment.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entityjndiAddresses- to be used to get references toEntityManagerandUserTransaction- Returns:
- a fully configured JPAContainer instance
-
makeJndi
Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em". Container also uses JTA transactions. This type of container commonly suits for JEE6 environment.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entity- Returns:
- a fully configured JPAContainer instance
-
makeJndi
Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em". Container also uses JTA transactions. This type of container commonly suits for JEE6 environment.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entityjndiAddresses- to be used to get references toEntityManagerandUserTransaction- Returns:
- a fully configured JPAContainer instance
-
makeBatchableJndi
Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em". Container also uses JTA transactions. This type of container commonly suits for JEE6 environment.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entity- Returns:
- a fully configured JPAContainer instance
-
makeBatchableJndi
public static <T> JPAContainer<T> makeBatchableJndi(Class<T> entityClass, JndiAddresses jndiAddresses) Creates a JPAContainer that uses JNDI lookups to fetch entity manager from "java:comp/env/persistence/em". Container also uses JTA transactions. This type of container commonly suits for JEE6 environment.- Type Parameters:
T- the type of entity to be contained in the JPAContainer- Parameters:
entityClass- the class of the entityjndiAddresses- to be used to get references toEntityManagerandUserTransaction- Returns:
- a fully configured JPAContainer instance
-