Package org.hibernate.boot
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.
-
ClassDescriptionLogging related to Hibernate bootstrappingModels the definition of caching settings for a particular region.Indicates a problem parsing the mapping document at a given
Origin
.Indicates a problem parsing a mapping document.Indicates that a mapping document could not be found at a givenOrigin
.Represents the ORM model as determined by aggregating the provided mapping sources.Contract for specifying various overrides to be used in metamodel building.Entry point for working with sources of O/R mapping metadata, either in the form of annotated classes, or as XML mapping documents.Abstraction for locating class-path resourcesAbstraction for locating class-path resourcesDefines the possible values for "hibernate.hbm2ddl.auto".The contract for building aSessionFactory
given a specified set of options.Enum describing how creation and dropping of temporary tables should be done in terms of transaction handling.Specialized exception indicating that an unsupportedorm.xml
XSD version was specified