Package org.hibernate.boot
packageorg.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, thenMetadataSourcesandMetadataBuilder, 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 theNative Bootstrapping guide for more details.
Included in subpackages under this namespace are:
- implementations of
ServiceRegistryused during the bootstrap process, - implementations of
MetadataBuilderandMetadata, andSessionFactoryBuilder, - support for
ImplicitNamingStrategyandPhysicalNamingStrategy, - 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 asHibernate Validator, and
- some SPIs used for schema management, including support for exportingauxiliary database objects, and for determining theorder of columns in generated DDL statements.
- Related PackagesPackageDescriptionThis package defines the central Hibernate APIs, beginning with
SessionFactory, which represents an instance of Hibernate at runtime and is the source of new instances ofSessionandStatelessSession, the most important APIs exposing persistence-related operations for entities.Support for integrating Jakarta Bean Validation.JAXB support fororm.xmlandhbm.xmlmapping filesThis package defines the boot-time metamodel, which is an interpretation of the domain model (entity classes, embeddable classes, and attributes) and the mapping of these "domain model parts" to the database.Overall, this module is responsible for takingmanaged-resources and building thehibernate-modelsmodel (ClassDetails, etc.) to ultimately be bound into Hibernate'sboot-time model.Support for handling named queries during the bootstrap process.Definesservice registry contracts a program may use for configuring Hibernate.A range of SPIs allowing integration with—and customization of—the process of building metadata.Support for XSD handling. - 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 resourcesDeprecated, for removal: This API element is subject to removal in a future version.This enumeration is currently unused and will be removed.The contract for building aSessionFactorygiven a specified set of options.Deprecated.All dialects currently useTempTableDdlTransactionHandling.NONE, so it's obsolete.Specialized exception indicating that an unsupportedorm.xmlXSD version was specified