Class HibernatePersistenceConfiguration

java.lang.Object
jakarta.persistence.PersistenceConfiguration
org.hibernate.jpa.HibernatePersistenceConfiguration

public class HibernatePersistenceConfiguration extends PersistenceConfiguration
Extends the Jakarta Persistence-defined PersistenceConfiguration with operations specific to Hibernate.

An instance of Configuration may be obtained simply by instantiation, and may be used to aggregate:

Standard JPA configuration properties are enumerated by the supertype PersistenceConfiguration. All configuration properties understood by Hibernate are enumerated by AvailableSettings.

 SessionFactory factory = new HibernatePersistenceConfiguration()
     // scan classes for mapping annotations
     .managedClasses(Item.class, Bid.class, User.class)
     // set a configuration property
     .setProperty(PersistenceConfiguration.JDBC_DATASOURCE,
                  "java:comp/env/jdbc/test")
     .buildSessionFactory();
 

When instantiated, an instance of HibernatePersistenceConfiguration has its properties initially populated from the environment, including:

When a root URL is supplied, or when at least one JAR file URL is supplied, and when hibernate-scan-jandex or some other service implementing ScannerFactory is available, the given URLs are scanned for entity classes, embeddable classes, mapped superclasses, converters, and XML mappings, alleviating the need to call managedClass(java.lang.Class<?>) or mappingFile(java.lang.String).

Since:
7.0
API Note:
The specification explicitly encourages implementors to extend PersistenceConfiguration to accommodate vendor-specific extensions in a more typesafe way. Of course, programs which desire configuration logic to be portable between JPA providers should use PersistenceConfiguration directly.