Class Persistence


  • public class Persistence
    extends java.lang.Object
    Bootstrap class that provides access to an EntityManagerFactory.
    • 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.
    • 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
      • 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 unit
        properties - 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.