An instance of Configuration may be obtained simply by
instantiation, and may be used to aggregate:
Note that XML mappings may be expressed using the JPA orm.xml
format, or in Hibernate's legacy .hbm.xml format.
Configuration properties are enumerated by AvailableSettings.
SessionFactory factory = new Configuration()
// scan classes for mapping annotations
.addAnnotatedClass(Item.class)
.addAnnotatedClass(Bid.class)
.addAnnotatedClass(User.class)
// read package-level annotations of the named package
.addPackage("org.hibernate.auction")
// set a configuration property
.setProperty(AvailableSettings.DATASOURCE,
"java:comp/env/jdbc/test")
.getSessionFactory();
In addition, there are convenience methods for adding attribute converters, type contributors, entity name resolvers, SQL function descriptors, and auxiliary database objects, for setting naming strategies and a tenant id resolver, and more.
Finally, an instance of SessionFactoryBuilder is obtained by
calling buildSessionFactory().
Ultimately, this class simply delegates to MetadataBuilder and
StandardServiceRegistryBuilder to actually do the hard work of
building the SessionFactory.
Programs may directly use the APIs defined under org.,
as an alternative to using an instance of this class.
SessionFactory, AvailableSettings, org.hibernate.boot
| Modifier and Type | Class and Description |
|---|---|
| private static interface |
| Access | Constructor and Description |
|---|---|
| public | Configuration()
Create a new instance, using a default |
| public | Configuration(BootstrapServiceRegistry serviceRegistry)
Create a new instance, using the given |
| public | Configuration(MetadataSources metadataSources)
Create a new instance, using the given |
| Modifier and Type | Method and Description |
|---|---|
| public Configuration | Returns: this for method chainingThe class containing annotations annotatedClass)Read metadata from the annotations associated with this class. |
| public Configuration | Returns: this for method chainingThe attributeConverterClass, boolean AttributeConverter class.Should the autoApply)AttributeConverter be auto applied to
property types as specified by its "entity attribute"
parameterized type?Adds an |
| public Configuration | Returns: this for method chainingThe attributeConverterClass)AttributeConverter class.Adds an |
| public Configuration | Returns: this for method chainingThe attributeConverter)AttributeConverter instance.Adds an |
| public Configuration | Returns: this for method chainingThe attributeConverter, boolean AttributeConverter instance.Should the autoApply)AttributeConverter be auto applied
to property types as specified by its "entity attribute"
parameterized type?Adds an |
| public Configuration | Returns: this for method chainingThe converterDescriptor)ConverterDescriptor instance.Adds an |
| public Configuration | Returns: this for method chainingAdds an |
| public Configuration | Returns: this for method chainingThe cacheable mapping file to be added. xmlFile)Add a cacheable mapping file. |
| public Configuration | Returns: this for method chainingThe name of the file to be added, in a form usable to
simply construct a xmlFile)File instanceAdd a cacheable mapping file. |
| public Configuration | Returns: this for method chainingThe xml file, not the bin! xmlFile)INTENDED FOR TESTSUITE USE ONLY! |
| public Configuration | Returns: this for method chainingThe mapped class entityClass)Read a mapping as an application resource using the convention that a class
named |
| public Configuration | Returns: this for method chainingThe directory dir)Read all |
| public Configuration | Returns: this for method chainingThe entityNameResolver)EntityNameResolver instance.Add an |
| public Configuration | |
| public Configuration | |
| public Configuration | Returns: this for method chainingThe input stream containing a DOM. xmlInputStream)Read mappings from an |
| public Configuration | |
| public Configuration | Returns: this for method chainingjava package name packageName)Read package-level metadata. |
| public Configuration | Returns: this for method chainingThe properties to add. properties)Add the given properties to ours. |
| public Configuration | Returns: this for method chainingThe resource name resourceName)Read mappings as an application resource name, that is, using a classpath lookup, trying different class loaders in turn. |
| public Configuration | Returns: this for method chainingAdds a SQL function descriptor to this configuration. |
| public Configuration | |
| public Configuration | Returns: this for method chainingthe parsed mapping binding)Read mappings that were parsed using |
| public SessionFactory | Returns: The newly-builtSessionFactoryThe registry of services to be used in creating this session factory. serviceRegistry)Create a |
| public SessionFactory | Returns: The newly-builtSessionFactoryCreate a |
| public Configuration | Returns: this for method chainingUse the mappings and properties specified in an application resource named
|
| public Configuration | |
| public Configuration | |
| public Configuration | |
| private XmlMappingBinderAccess | |
| private static BootstrapServiceRegistry | |
| public ColumnOrderingStrategy | getColumnOrderingStrategy()
The |
| public CurrentTenantIdentifierResolver | getCurrentTenantIdentifierResolver()
The |
| public CustomEntityDirtinessStrategy | getCustomEntityDirtinessStrategy()
The |
| public EntityNotFoundDelegate | Returns: The user-supplied delegateRetrieve the user-supplied |
| public ImplicitNamingStrategy | |
| public Interceptor | |
| public Collection | |
| public Map | |
| public Map | |
| public Map | |
| public PhysicalNamingStrategy | |
| public Properties | |
| public String | Returns: The value currently associated with that property name; may be null.The name of the property propertyName)Get a property value by name |
| public SessionFactoryObserver | getSessionFactoryObserver()
The |
| public Map | |
| public Map | |
| public StandardServiceRegistryBuilder | |
| public StatementInspector | |
| public XmlMappingBinderAccess | getXmlMappingBinderAccess()
An object capable of parsing XML mapping files that can then be passed
to |
| public Configuration | Returns: this for method chainingThe properties to merge properties)Adds the incoming properties to the internal properties structure, as long as the internal structure does not already contain an entry for the given key. |
| public Configuration | Returns: this for method chainingAdd a |
| public Configuration | Returns: this for method chainingAdd a |
| public Configuration | Returns: this for method chainingThe type to register. type)Register a type into the type registry, potentially replacing a previously registered type. |
| public Configuration | Returns: this for method chainingThe type to register. type, String[] The keys under which to register the type. keys)Register a type into the type registry, potentially replacing a previously registered type. |
| protected void | |
| public Configuration | Returns: this for method chainingSpecify a |
| public Configuration | Returns: this for method chainingSpecify a |
| public Configuration | Returns: this for method chainingSpecify a |
| public Configuration | Returns: this for method chainingThe delegate to use entityNotFoundDelegate)Specify a user-supplied |
| public Configuration | Returns: this for method chainingSet an |
| public Configuration | Returns: this for method chainingThe interceptor)Interceptor to useSet the current |
| public Configuration | Returns: this for method chainingSet a |
| public Configuration | Returns: this for method chainingThe new set of properties properties)Specify a completely new set of properties |
| public Configuration | Returns: this for method chainingThe name of the property to set propertyName, String The new property value value)Set a property value by name |
| public Configuration | Returns: this for method chainingSpecify a |
| public Configuration | Returns: this for method chainingThe SharedCacheMode to use sharedCacheMode)Sets the |
| public Configuration | Returns: this for method chainingSpecify a |