Top Description Fields Constructors Methods
org.hibernate.cfg

public Class Configuration

extends Object
Class Inheritance
Annotations
@SuppressWarnings:UnusedDeclaration
Imports
java.io.File, .FileNotFoundException, .InputStream, java.net.URL, java.util.ArrayList, .Collections, .HashMap, .List, .Map, .Properties, javax.persistence.AttributeConverter, .SharedCacheMode, org.hibernate.EmptyInterceptor, .HibernateException, .Interceptor, .MappingException, .SessionFactory, .SessionFactoryObserver, org.hibernate.boot.Metadata, .MetadataBuilder, .MetadataSources, .SessionFactoryBuilder, org.hibernate.boot.jaxb.spi.Binding, org.hibernate.boot.model.TypeContributor, org.hibernate.boot.model.naming.ImplicitNamingStrategy, .ImplicitNamingStrategyJpaCompliantImpl, .PhysicalNamingStrategy, .PhysicalNamingStrategyStandardImpl, org.hibernate.boot.model.relational.AuxiliaryDatabaseObject, org.hibernate.boot.registry.BootstrapServiceRegistry, .BootstrapServiceRegistryBuilder, .StandardServiceRegistry, .StandardServiceRegistryBuilder, org.hibernate.boot.spi.XmlMappingBinderAccess, org.hibernate.cfg.annotations.NamedEntityGraphDefinition, .NamedProcedureCallDefinition, org.hibernate.context.spi.CurrentTenantIdentifierResolver, org.hibernate.dialect.function.SQLFunction, org.hibernate.engine.ResultSetMappingDefinition, org.hibernate.engine.spi.NamedQueryDefinition, .NamedSQLQueryDefinition, org.hibernate.internal.CoreLogging, .CoreMessageLogger, org.hibernate.internal.util.xml.XmlDocument, org.hibernate.proxy.EntityNotFoundDelegate, org.hibernate.service.ServiceRegistry, org.hibernate.tuple.entity.EntityTuplizerFactory, org.hibernate.type.BasicType, .CompositeCustomType, .CustomType, .SerializationException, org.hibernate.usertype.CompositeUserType, .UserType

Represents one approach for bootstrapping Hibernate. In fact, historically this was the way to bootstrap Hibernate.

The approach here is to define all configuration and mapping sources in one API and to then build the org.hibernate.SessionFactory in one-shot. The configuration and mapping sources defined here are just held here until the SessionFactory is built. This is an important distinction from the legacy behavior of this class, where we would try to incrementally build the mappings from sources as they were added. The ramification of this change in behavior is that users can add configuration and mapping sources here, but they can no longer query the in-flight state of mappings (org.hibernate.mapping.PersistentClass, org.hibernate.mapping.Collection, etc) here.

Note

Internally this class uses the new bootstrapping approach when asked to build the SessionFactory.

Authors
Gavin King, Steve Ebersole
See Also
org.hibernate.SessionFactory

Field Summary

Modifier and TypeField and Description
public static final String
private HashMap<Class<T>, AttributeConverterDefinition>
private List<AuxiliaryDatabaseObject>
private List<BasicType>
private final BootstrapServiceRegistry
private CurrentTenantIdentifierResolver
private EntityNotFoundDelegate
private EntityTuplizerFactory
private ImplicitNamingStrategy
private Interceptor
private static final CoreMessageLogger
private final MetadataSources
private Map<String, NamedEntityGraphDefinition>
private Map<String, NamedProcedureCallDefinition>
private Map<String, NamedQueryDefinition>
private Map<String, NamedSQLQueryDefinition>
private PhysicalNamingStrategy
private Properties
private SessionFactoryObserver
private SharedCacheMode
private Map<String, SQLFunction>
private Map<String, ResultSetMappingDefinition>
private StandardServiceRegistryBuilder
private List<TypeContributor>

Constructor Summary

AccessConstructor and Description
public
public
public
Configuration(MetadataSources metadataSources)

Method Summary

Modifier and TypeMethod and Description
public void
add(XmlDocument metadataXml)

Deprecated No longer supported.
public Configuration

Returns:

this (for method chaining)
addAnnotatedClass
(Class<T>
The class containing annotations
annotatedClass
)

Read metadata from the annotations associated with this class.

public void
addAttributeConverter(Class<? extends AttributeConverter<X, Y>>
The AttributeConverter class.
attributeConverterClass
,
boolean
Should the AttributeConverter be auto applied to property types as specified by its "entity attribute" parameterized type?
autoApply
)

Adds the AttributeConverter Class to this Configuration.

public void
addAttributeConverter(Class<? extends AttributeConverter<X, Y>>
The AttributeConverter class.
attributeConverterClass
)

Adds the AttributeConverter Class to this Configuration.

public void
addAttributeConverter(AttributeConverter<X, Y>
The AttributeConverter instance.
attributeConverter
)

Adds the AttributeConverter instance to this Configuration.

public void
addAttributeConverter(AttributeConverter<X, Y>
The AttributeConverter instance.
attributeConverter
,
boolean
Should the AttributeConverter be auto applied to property types as specified by its "entity attribute" parameterized type?
autoApply
)

Adds the AttributeConverter instance to this Configuration.

public void
addAttributeConverter(AttributeConverterDefinition definition)

Deprecated as a consequence of AttributeConverterDefinition being deprecated.
public void
public Configuration

Returns:

this (for method chaining purposes)
addCacheableFile
(File
The cacheable mapping file to be added.
xmlFile
)

Add a cached mapping file.

public Configuration

Returns:

this (for method chaining purposes)
addCacheableFile
(String
The name of the file to be added. This must be in a form useable to simply construct a java.io.File instance.
xmlFile
)

Add a cacheable mapping file.

public Configuration

Returns:

The dom "deserialized" from the cached file.
addCacheableFileStrictly
(File
The xml file, not the bin!
xmlFile
)

INTENDED FOR TESTSUITE USE ONLY!

public Configuration

Returns:

this (for method chaining purposes)
addClass
(Class<T>
The mapped class
persistentClass
)

Read a mapping as an application resource using the convention that a class named foo.bar.Foo is mapped by a file foo/bar/Foo.hbm.xml which can be resolved as a classpath resource.

public Configuration

Returns:

this (for method chaining purposes)
addDirectory
(File
The directory
dir
)

Read all mapping documents from a directory tree.

public Configuration

Returns:

this (for method chaining purposes)
addDocument
(Document
The DOM document
doc
)

Deprecated Use addURL, addResource, addFile, etc. instead
Read mappings from a DOM Document
public Configuration

Returns:

this (for method chaining purposes)
addFile
(String
a path to a file
xmlFile
)

Read mappings from a particular XML file

public Configuration

Returns:

this (for method chaining purposes)
addFile
(File
a path to a file
xmlFile
)

Read mappings from a particular XML file

public Configuration

Returns:

this (for method chaining purposes)
addInputStream
(InputStream
The input stream containing a DOM.
xmlInputStream
)

Read mappings from an java.io.InputStream.

public Configuration

Returns:

this (for method chaining purposes)
addJar
(File
a jar file
jar
)

Read all mappings from a jar file

Assumes that any file named *.hbm.xml is a mapping document.

public Configuration

Returns:

this (for method chaining)
addPackage
(String
java package name
packageName
)

Read package-level metadata.

public Configuration

Returns:

this for method chaining
addProperties
(Properties
The properties to add.
properties
)

Add the given properties to ours.

public Configuration
addResource(String resourceName, ClassLoader classLoader)

Deprecated This form (accepting a ClassLoader) is no longer supported. Instead, add the ClassLoader to the ClassLoaderService on the ServiceRegistry associated with this Configuration
public Configuration

Returns:

this (for method chaining purposes)
addResource
(String
The resource name
resourceName
)

Read mappings as a application resourceName (i.e. classpath lookup) trying different class loaders.

public void
addSqlFunction(String functionName, SQLFunction function)

public Configuration

Returns:

this (for method chaining purposes)
addURL
(URL
The url for the mapping document to be read.
url
)

Read mappings from a URL

public Configuration
addXML(String xml)

Deprecated No longer supported
public Configuration

Returns:

this (for method chaining purposes)
addXmlMapping
(Binding<?>
the parsed mapping
binding
)

Read mappings that were parsed using getXmlMappingBinderAccess().

public void
buildMappings()

Deprecated Does nothing
public SessionFactory

Returns:

The built SessionFactory
buildSessionFactory
(ServiceRegistry
The registry of services to be used in creating this session factory.
serviceRegistry
)

Deprecated as a consequence of SessionFactory being deprecated.
Create a SessionFactory using the properties and mappings in this configuration.
public SessionFactory

Returns:

The build SessionFactory
buildSessionFactory
()

Deprecated as a consequence of SessionFactory being deprecated.
Create a SessionFactory using the properties and mappings in this configuration.
public Configuration

Returns:

this for method chaining
configure
()

Use the mappings and properties specified in an application resource named hibernate.cfg.xml.

public Configuration

Returns:

this for method chaining
configure
(String
The resource to use
resource
)

Use the mappings and properties specified in the given application resource.

public Configuration

Returns:

this for method chaining
configure
(URL
URL from which you wish to load the configuration
url
)

Use the mappings and properties specified in the given document.

public Configuration

Returns:

this for method chaining
configure
(File
File from which you wish to load the configuration
configFile
)

Use the mappings and properties specified in the given application file.

public Configuration
configure(Document document)

Deprecated No longer supported.
private static BootstrapServiceRegistry
public CurrentTenantIdentifierResolver
public EntityNotFoundDelegate

Returns:

The user-supplied delegate
getEntityNotFoundDelegate
()

Retrieve the user-supplied delegate to handle non-existent entity scenarios.

public EntityTuplizerFactory
public Interceptor

Returns:

The current Interceptor
getInterceptor
()

Retrieve the configured Interceptor.

public Collection<NamedEntityGraphDefinition>
public Map<String, NamedProcedureCallDefinition>
public Map<String, NamedQueryDefinition>
public Map<K, V>
public Properties

Returns:

all properties
getProperties
()

Get all properties

public String

Returns:

The value currently associated with that property name; may be null.
getProperty
(String
The name of the property
propertyName
)

Get a property value by name

public SessionFactoryObserver
public Map<String, SQLFunction>
public Map<K, V>
public StandardServiceRegistryBuilder
getStandardServiceRegistryBuilder()

Intended for internal testing use only!!!

public XmlMappingBinderAccess

Returns:

An object capable of parsing XML mapping files that can then be passed to addXmlMapping(Binding).
getXmlMappingBinderAccess
()

public Configuration

Returns:

this for method chaining
mergeProperties
(Properties
The 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
public Configuration
registerTypeOverride(BasicType
The type to register.
type
)

Allows registration of a type into the type registry.

public Configuration
public Configuration
protected void
public void
public void
setEntityNotFoundDelegate(EntityNotFoundDelegate
The delegate to use
entityNotFoundDelegate
)

Specify a user-supplied delegate to be used to handle scenarios where an entity could not be located by specified id. This is mainly intended for EJB3 implementations to be able to control how proxy initialization errors should be handled...

public void
public Configuration

Returns:

this for method chaining
setInterceptor
(Interceptor
The Interceptor to use for the built SessionFactory.
interceptor
)

Set the current Interceptor

public void
public Configuration

Returns:

this for method chaining
setProperties
(Properties
The new set of properties
properties
)

Specify a completely new set of properties

public Configuration

Returns:

this for method chaining
setProperty
(String
The name of the property to set
propertyName
,
String
The new property value
value
)

Set a property value by name

public void
public void
setSharedCacheMode(SharedCacheMode
The SharedCacheMode to use
sharedCacheMode
)

Sets the SharedCacheMode to use.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait