Top Description Interfaces Classes Enums
[default module]

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 org.hibernate.SessionFactory.

Configuring Hibernate using these APIs usually involves working with:

  1. org.hibernate.boot.registry.StandardServiceRegistryBuilder, then
  2. org.hibernate.boot.MetadataSources and org.hibernate.boot.MetadataBuilder, and
  3. finally, with org.hibernate.boot.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, org.hibernate.boot.registry.BootstrapServiceRegistryBuilder might also be used.

See the Native Bootstrapping guide for more details.

Included in subpackages under this namespace are:

Interface Summary

Modifier and TypeInterface and Description
public interface
AttributeConverterInfo

Deprecated for removal since 6.2. no longer used
Delayed information about an AttributeConverter.
public interface
BootLogging

Logging related to Hibernate bootstrapping

public interface
Metadata

Deprecated as a consequence of Mapping being deprecated.
Represents the ORM model as determined by aggregating the provided mapping sources.
public interface
MetadataBuilder

Contract for specifying various overrides to be used in metamodel building.

public interface
ResourceLocator

Abstraction for locating class-path resources

public interface
ResourceStreamLocator

Abstraction for locating class-path resources

public interface
SessionFactoryBuilder

The contract for building a SessionFactory given a number of options.

Class Summary

Modifier and TypeClass and Description
public class
CacheRegionDefinition

Models the definition of caching settings for a particular region.

public class
InvalidMappingException

Indicates a problem parsing the mapping document at a given Origin.

public class
MappingException

Indicates a problem parsing a mapping document.

public class
MappingNotFoundException

Indicates that a mapping document could not be found at a given Origin.

public class
MetadataSources

Entry point for working with sources of O/R mapping metadata, either in the form of annotated classes, or as XML mapping documents.

public class
UnsupportedOrmXsdVersionException

Specialized exception indicating that an unsupported orm.xml XSD version was specified

Enum Summary

Modifier and TypeEnum and Description
public enum
SchemaAutoTooling

Defines the possible values for hibernate.hbm2ddl.auto.

public enum
TempTableDdlTransactionHandling

Enum describing how creation and dropping of temporary tables should be done in terms of transaction handling.