javax.persistence
Class Persistence

java.lang.Object
  extended by javax.persistence.Persistence

public class Persistence
extends java.lang.Object

Bootstrap class that is used to obtain an EntityManagerFactory.

Since:
EJB 3.0 version.
Author:
Florent Benoit
See Also:
EJB 3.0 specification

Field Summary
private static boolean initialized
          Persistence providers have been initialized ?
static java.lang.String PERSISTENCE_PROVIDER
          Persistence Provider property.
private static java.lang.String PERSISTENCE_PROVIDER_JAR_PROPERTY
          The provider supplies the provider configuration file by creating a text file named javax.persistence.spi.PersistenceProvider and placing it in the META-INF/services directory of one of its JAR files.
private static java.lang.String PERSISTENCE_PROVIDER_MAP_PROPERTY
          Property present in the map ?
The javax.persistence.provider property was included in the Map passed to createEntityManagerFactory and the value of the property is the provider's implementation class.
protected static java.util.Set<PersistenceProvider> providers
          Set of persistence providers.
 
Constructor Summary
Persistence()
           
 
Method Summary
private static void addPersistenceProvider(java.lang.String persistenceProviderName)
          Add to the set of persistence provider the given persistence provider (by using its name).
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.
private static PersistenceProvider getProviderForName(java.lang.String persistenceProviderName)
          Gets a persistence provider for the given persistence provider name.
private static void init()
          Initialize the list of persistence providers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERSISTENCE_PROVIDER

public static java.lang.String PERSISTENCE_PROVIDER
Persistence Provider property.


providers

protected static final java.util.Set<PersistenceProvider> providers
Set of persistence providers.


PERSISTENCE_PROVIDER_JAR_PROPERTY

private static final java.lang.String PERSISTENCE_PROVIDER_JAR_PROPERTY
The provider supplies the provider configuration file by creating a text file named javax.persistence.spi.PersistenceProvider and placing it in the META-INF/services directory of one of its JAR files. The contents of the file should be the name of the provider implementation class of the javax.persistence.spi.PersistenceProvider interface.


PERSISTENCE_PROVIDER_MAP_PROPERTY

private static final java.lang.String PERSISTENCE_PROVIDER_MAP_PROPERTY
Property present in the map ?
The javax.persistence.provider property was included in the Map passed to createEntityManagerFactory and the value of the property is the provider's implementation class.

See Also:
Constant Field Values

initialized

private static boolean initialized
Persistence providers have been initialized ?

Constructor Detail

Persistence

public Persistence()
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 unit
properties - 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.

getProviderForName

private static PersistenceProvider getProviderForName(java.lang.String persistenceProviderName)
Gets a persistence provider for the given persistence provider name.

Parameters:
persistenceProviderName - the given persistence provider name.
Returns:
an instance of persistence provider if found, else null.

init

private static void init()
Initialize the list of persistence providers. (it not done).


addPersistenceProvider

private static void addPersistenceProvider(java.lang.String persistenceProviderName)
Add to the set of persistence provider the given persistence provider (by using its name).

Parameters:
persistenceProviderName - name of the persistence provider.