Package org.hibernate.boot
This package contains the interfaces that make up the bootstrap API
for Hibernate. They collectively provide a way to specify configuration
information and construct a new instance of
SessionFactory
.
Configuring Hibernate using these APIs usually involves working with:
StandardServiceRegistryBuilder
, thenMetadataSources
andMetadataBuilder
, and- finally, with
SessionFactoryBuilder
.
StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder() // supply a configuration .configure("org/hibernate/example/hibernate.cfg.xml") // set a configuration property .applySetting(AvailableSettings.HBM2DDL_AUTO, SchemaAutoTooling.CREATE_DROP.externalForm()) .build(); MetadataBuilder metadataBuilder = new MetadataSources(standardRegistry) // supply annotated classes .addAnnotatedClass(MyEntity.class) .addAnnotatedClassName("org.hibernate.example.Customer") // supply XML-based mappings .addResource("org/hibernate/example/Order.hbm.xml") .addResource("org/hibernate/example/Product.orm.xml") .getMetadataBuilder(); Metadata metadata = metadataBuilder // set the naming strategies .applyImplicitNamingStrategy(ImplicitNamingStrategyJpaCompliantImpl.INSTANCE) .applyPhysicalNamingStrategy(new CustomPhysicalNamingStrategy()) // add a TypeContributor .applyTypes(new CustomTypeContributor()) .build(); SessionFactoryBuilder sessionFactoryBuilder = metadata.getSessionFactoryBuilder(); SessionFactory sessionFactory = sessionFactoryBuilder // supply a factory-level Interceptor .applyInterceptor(new CustomSessionFactoryInterceptor()); // add a custom observer .addSessionFactoryObservers(new CustomSessionFactoryObserver()); // apply a CDI BeanManager (for JPA event listeners) .applyBeanManager(getBeanManager()); .build();
In more advanced scenarios,
BootstrapServiceRegistryBuilder
might also be used.
See the Native Bootstrapping guide for more details.
Included in subpackages under this namespace are:
- implementations of
ServiceRegistry
used during the bootstrap process, - implementations of
MetadataBuilder
andMetadata
, andSessionFactoryBuilder
, - support for
ImplicitNamingStrategy
andPhysicalNamingStrategy
, - a range of SPIs allowing integration with the process of building metadata,
- internal code for parsing and interpreting mapping information declared in XML or using annotations,
- support for integrating an implementation of Bean Validation, such as Hibernate Validator, and
- some SPIs used for schema management, including support for exporting auxiliary database objects, and for determining the order of columns in generated DDL statements.
-
Interface Summary Interface Description AttributeConverterInfo Deprecated, for removal: This API element is subject to removal in a future version. no longer usedBootLogging Logging related to Hibernate bootstrappingMetadata Represents the ORM model as determined by aggregating the provided mapping sources.MetadataBuilder Contract for specifying various overrides to be used in metamodel building.ResourceLocator Abstraction for locating class-path resourcesResourceStreamLocator Abstraction for locating class-path resourcesSessionFactoryBuilder The contract for building aSessionFactory
given a specified set of options. -
Class Summary Class Description CacheRegionDefinition Models the definition of caching settings for a particular region.MetadataSources Entry point for working with sources of O/R mapping metadata, either in the form of annotated classes, or as XML mapping documents. -
Enum Summary Enum Description CacheRegionDefinition.CacheRegionType SchemaAutoTooling Defines the possible values for "hibernate.hbm2ddl.auto".TempTableDdlTransactionHandling Enum describing how creation and dropping of temporary tables should be done in terms of transaction handling. -
Exception Summary Exception Description InvalidMappingException Indicates a problem parsing the mapping document at a givenOrigin
.MappingException Indicates a problem parsing a mapping document.MappingNotFoundException Indicates that a mapping document could not be found at a givenOrigin
.UnsupportedOrmXsdVersionException Specialized exception indicating that an unsupportedorm.xml
XSD version was specified