Package javax.persistence
Class Persistence
- java.lang.Object
-
- javax.persistence.Persistence
-
public class Persistence extends java.lang.Object
Bootstrap class that provides access to an EntityManagerFactory.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PERSISTENCE_PROVIDER
Deprecated.protected static java.util.Set<PersistenceProvider>
providers
Deprecated.private static PersistenceUtil
util
-
Constructor Summary
Constructors Constructor Description Persistence()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static EntityManagerFactory
createEntityManagerFactory(java.lang.String persistenceUnitName)
Create and return an EntityManagerFactory for the named persistence unit.static EntityManagerFactory
createEntityManagerFactory(java.lang.String persistenceUnitName, java.util.Map properties)
Create and return an EntityManagerFactory for the named persistence unit using the given properties.static void
generateSchema(java.lang.String persistenceUnitName, java.util.Map properties)
Create database schemas and/or tables and/or create DDL scripts as determined by the supplied properties Called when schema generation is to occur as a separate phase from creation of the entity manager factory.static PersistenceUtil
getPersistenceUtil()
private static java.util.List<PersistenceProvider>
getProviders()
-
-
-
Field Detail
-
PERSISTENCE_PROVIDER
@Deprecated public static final java.lang.String PERSISTENCE_PROVIDER
Deprecated.- See Also:
- Constant Field Values
-
providers
@Deprecated protected static final java.util.Set<PersistenceProvider> providers
Deprecated.
-
util
private static PersistenceUtil util
-
-
Method Detail
-
createEntityManagerFactory
public static EntityManagerFactory createEntityManagerFactory(java.lang.String persistenceUnitName)
Create and return an EntityManagerFactory for the named persistence unit.- Parameters:
persistenceUnitName
- The name of the persistence unit- Returns:
- The factory that creates EntityManagers configured according to the specified persistence unit
-
createEntityManagerFactory
public static EntityManagerFactory createEntityManagerFactory(java.lang.String persistenceUnitName, java.util.Map properties)
Create and return an EntityManagerFactory for the named persistence unit using the given properties.- Parameters:
persistenceUnitName
- The name of the persistence unitproperties
- Additional properties to use when creating the factory. The values of these properties override any values that may have been configured elsewhere- Returns:
- The factory that creates EntityManagers configured according to the specified persistence unit
-
getProviders
private static java.util.List<PersistenceProvider> getProviders()
-
generateSchema
public static void generateSchema(java.lang.String persistenceUnitName, java.util.Map properties)
Create database schemas and/or tables and/or create DDL scripts as determined by the supplied properties Called when schema generation is to occur as a separate phase from creation of the entity manager factory.- Parameters:
persistenceUnitName
- the name of the persistence unitproperties
- properties for schema generation; these may also contain provider-specific properties. The values of these properties override any values that may have been configured elsewhere.- Throws:
PersistenceException
- if insufficient or inconsistent configuration information is provided or if schema generation otherwise fails.
-
getPersistenceUtil
public static PersistenceUtil getPersistenceUtil()
- Returns:
- Returns a
PersistenceUtil
instance.
-
-