public class

Configuration

extends Object
implements Serializable
java.lang.Object
   ↳ org.hibernate.cfg.Configuration
Known Direct Subclasses

Class Overview

An instance of Configuration allows the application to specify properties and mapping documents to be used when creating a SessionFactory. Usually an application will create a single Configuration, build a single instance of SessionFactory and then instantiate Sessions in threads servicing client requests. The Configuration is meant only as an initialization-time object. SessionFactorys are immutable and do not retain any association back to the Configuration.

A new Configuration will use the properties specified in hibernate.properties by default.

See Also

Summary

Nested Classes
class Configuration.MappingsImpl Internal implementation of the Mappings interface giving access to the Configuration's internal metadata repository state (classes, tables, etc). 
class Configuration.MetadataSourceQueue  
Constants
String ARTEFACT_PROCESSING_ORDER
String DEFAULT_CACHE_CONCURRENCY_STRATEGY Setting used to give the name of the default CacheConcurrencyStrategy to use when either javax.persistence.Cacheable @Cacheable or @Cache is used.
String USE_NEW_ID_GENERATOR_MAPPINGS Setting which indicates whether or not the new IdentifierGenerator are used for AUTO, TABLE and SEQUENCE.
Fields
public static final MetadataSourceType[] DEFAULT_ARTEFACT_PROCESSING_ORDER
protected List<AuxiliaryDatabaseObject> auxiliaryDatabaseObjects
protected Map<StringPersistentClass> classes
protected Map<StringCollection> collections
protected Map columnNameBindingPerTable
protected Map<ExtendsQueueEntry, ?> extendsQueue
protected Map<StringFetchProfile> fetchProfiles
protected Map<StringFilterDefinition> filterDefinitions
protected Map<StringString> imports
protected Configuration.MetadataSourceQueue metadataSourceQueue
protected Map<StringNamedQueryDefinition> namedQueries
protected Map<StringNamedSQLQueryDefinition> namedSqlQueries
protected NamingStrategy namingStrategy
protected List<Mappings.PropertyReference> propertyReferences
protected List<SecondPass> secondPasses
protected final SettingsFactory settingsFactory
protected Map<StringSQLFunction> sqlFunctions
protected Map<StringResultSetMappingDefinition> sqlResultSetMappings
protected Map tableNameBinding
protected Map<StringTable> tables
protected Map<StringTypeDef> typeDefs
protected XMLHelper xmlHelper
Public Constructors
Configuration()
Protected Constructors
Configuration(SettingsFactory settingsFactory)
Public Methods
void add(XmlDocument metadataXml)
Configuration addAnnotatedClass(Class annotatedClass)
Read metadata from the annotations associated with this class.
void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject object)
Configuration addCacheableFile(File xmlFile)
Add a cached mapping file.
Configuration addCacheableFile(String xmlFile)
Add a cacheable mapping file.
Configuration addCacheableFileStrictly(File xmlFile)
INTENDED FOR TESTSUITE USE ONLY!

Much like addCacheableFile(File) except that here we will fail immediately if the cache version cannot be found or used for whatever reason

Configuration addClass(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.
Configuration addDirectory(File dir)
Read all mapping documents from a directory tree.
Configuration addDocument(Document doc)
Read mappings from a DOM Document
void addFetchProfile(FetchProfile fetchProfile)
Configuration addFile(File xmlFile)
Read mappings from a particular XML file
Configuration addFile(String xmlFile)
Read mappings from a particular XML file
void addFilterDefinition(FilterDefinition definition)
Configuration addInputStream(InputStream xmlInputStream)
Read mappings from an InputStream.
Configuration addJar(File jar)
Read all mappings from a jar file

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

Configuration addPackage(String packageName)
Read package-level metadata.
Configuration addProperties(Properties extraProperties)
Add the given properties to ours.
Configuration addResource(String resourceName)
Read mappings as a application resourceName (i.e.
Configuration addResource(String resourceName, ClassLoader classLoader)
Read mappings as a application resource (i.e.
void addSqlFunction(String functionName, SQLFunction function)
Configuration addURL(URL url)
Read mappings from a URL
Configuration addXML(String xml)
Read mappings from a String
Mapping buildMapping()
void buildMappings()
Call this to ensure the mappings are fully compiled/built.
SessionFactory buildSessionFactory()
Create a SessionFactory using the properties and mappings in this configuration.
Settings buildSettings(Properties props)
Settings buildSettings()
Create an object-oriented view of the configuration properties
Configuration configure(File configFile)
Use the mappings and properties specified in the given application file.
Configuration configure(Document document)
Use the mappings and properties specified in the given XML document.
Configuration configure(URL url)
Use the mappings and properties specified in the given document.
Configuration configure()
Use the mappings and properties specified in an application resource named hibernate.cfg.xml.
Configuration configure(String resource)
Use the mappings and properties specified in the given application resource.
Mappings createMappings()
Create a new Mappings to add class and collection mappings to.
String[] generateDropSchemaScript(Dialect dialect)
Generate DDL for dropping tables
String[] generateSchemaCreationScript(Dialect dialect)
String[] generateSchemaUpdateScript(Dialect dialect, DatabaseMetadata databaseMetadata)
PersistentClass getClassMapping(String entityName)
Get the mapping for a particular entity
Iterator<PersistentClass> getClassMappings()
Iterate the entity mappings
Collection getCollectionMapping(String role)
Get the mapping for a particular collection role
Iterator getCollectionMappings()
Iterate the collection mappings
EntityNotFoundDelegate getEntityNotFoundDelegate()
Retrieve the user-supplied delegate to handle non-existent entity scenarios.
EntityResolver getEntityResolver()
EntityTuplizerFactory getEntityTuplizerFactory()
EventListeners getEventListeners()
Map getFilterDefinitions()
DefaultIdentifierGeneratorFactory getIdentifierGeneratorFactory()
Retrieve the IdentifierGeneratorFactory in effect for this configuration.
Map<StringString> getImports()
Get the query language imports
Interceptor getInterceptor()
Rterieve the configured Interceptor.
Iterator<MappedSuperclass> getMappedSuperclassMappings()
Iterate the mapped super class mappings EXPERIMENTAL Consider this API as PRIVATE
Map<StringNamedQueryDefinition> getNamedQueries()
Map getNamedSQLQueries()
NamingStrategy getNamingStrategy()
PersisterClassProvider getPersisterClassProvider()
Properties getProperties()
Get all properties
String getProperty(String propertyName)
Get a property value by name
ReflectionManager getReflectionManager()
SessionFactoryObserver getSessionFactoryObserver()
Map getSqlFunctions()
Map getSqlResultSetMappings()
Iterator<Table> getTableMappings()
Iterate the table mappings
TypeResolver getTypeResolver()
Iterator iterateFetchProfiles()
Configuration mergeProperties(Properties 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.
void registerTypeOverride(CompositeUserType type, String[] keys)
void registerTypeOverride(BasicType type)
Allows registration of a type into the type registry.
void registerTypeOverride(UserType type, String[] keys)
Configuration setCacheConcurrencyStrategy(String entityName, String concurrencyStrategy)
Set up a cache for an entity class
Configuration setCacheConcurrencyStrategy(String entityName, String concurrencyStrategy, String region)
Set up a cache for an entity class, giving an explicit region name
void setCacheConcurrencyStrategy(String entityName, String concurrencyStrategy, String region, boolean cacheLazyProperty)
void setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy, String region)
Set up a cache for a collection role, giving an explicit region name
Configuration setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy)
Set up a cache for a collection role
void setEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate)
Specify a user-supplied delegate to be used to handle scenarios where an entity could not be located by specified id.
void setEntityResolver(EntityResolver entityResolver)
Set a custom entity resolver.
Configuration setInterceptor(Interceptor interceptor)
Set the current Interceptor
void setListener(String type, String listener)
void setListener(String type, Object listener)
void setListeners(String type, String[] listenerClasses)
void setListeners(String type, Object[] listeners)
Configuration setNamingStrategy(NamingStrategy namingStrategy)
Set a custom naming strategy
Configuration setPersisterClassProvider(PersisterClassProvider persisterClassProvider)
Defines a custom persister class provider.
void setPrecedence(String precedence)
Configuration setProperties(Properties properties)
Specify a completely new set of properties
Configuration setProperty(String propertyName, String value)
Set a property value by name
void setSessionFactoryObserver(SessionFactoryObserver sessionFactoryObserver)
void validateSchema(Dialect dialect, DatabaseMetadata databaseMetadata)
Protected Methods
Configuration doConfigure(Document doc)
Parse a dom4j document conforming to the Hibernate Configuration DTD (hibernate-configuration-3.0.dtd) and use its information to configure this Configuration's state
Configuration doConfigure(InputStream stream, String resourceName)
Configure this configuration's state from the contents of the given input stream.
ExtendsQueueEntry findPossibleExtends()
InputStream getConfigurationInputStream(String resource)
Get the configuration file as an InputStream.
void reset()
void secondPassCompile()
void secondPassCompileForeignKeys(Table table, Set done)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ARTEFACT_PROCESSING_ORDER

Constant Value: "hibernate.mapping.precedence"

public static final String DEFAULT_CACHE_CONCURRENCY_STRATEGY

Setting used to give the name of the default CacheConcurrencyStrategy to use when either javax.persistence.Cacheable @Cacheable or @Cache is used. @Cache(strategy="..") is used to override.

Constant Value: "hibernate.cache.default_cache_concurrency_strategy"

public static final String USE_NEW_ID_GENERATOR_MAPPINGS

Setting which indicates whether or not the new IdentifierGenerator are used for AUTO, TABLE and SEQUENCE. Default to false to keep backward compatibility.

Constant Value: "hibernate.id.new_generator_mappings"

Fields

public static final MetadataSourceType[] DEFAULT_ARTEFACT_PROCESSING_ORDER

protected List<AuxiliaryDatabaseObject> auxiliaryDatabaseObjects

protected Map<StringPersistentClass> classes

protected Map<StringCollection> collections

protected Map columnNameBindingPerTable

protected Map<ExtendsQueueEntry, ?> extendsQueue

protected Map<StringFetchProfile> fetchProfiles

protected Map<StringFilterDefinition> filterDefinitions

protected Map<StringString> imports

protected Configuration.MetadataSourceQueue metadataSourceQueue

protected Map<StringNamedQueryDefinition> namedQueries

protected Map<StringNamedSQLQueryDefinition> namedSqlQueries

protected NamingStrategy namingStrategy

protected List<Mappings.PropertyReference> propertyReferences

protected List<SecondPass> secondPasses

protected final SettingsFactory settingsFactory

protected Map<StringSQLFunction> sqlFunctions

protected Map<StringResultSetMappingDefinition> sqlResultSetMappings

protected Map tableNameBinding

protected Map<StringTable> tables

protected Map<StringTypeDef> typeDefs

protected XMLHelper xmlHelper

Public Constructors

public Configuration ()

Protected Constructors

protected Configuration (SettingsFactory settingsFactory)

Public Methods

public void add (XmlDocument metadataXml)

public Configuration addAnnotatedClass (Class annotatedClass)

Read metadata from the annotations associated with this class.

Parameters
annotatedClass The class containing annotations
Returns
  • this (for method chaining)

public void addAuxiliaryDatabaseObject (AuxiliaryDatabaseObject object)

public Configuration addCacheableFile (File xmlFile)

Add a cached mapping file. A cached file is a serialized representation of the DOM structure of a particular mapping. It is saved from a previous call as a file with the name xmlFile + ".bin" where xmlFile is the name of the original mapping file.

If a cached xmlFile + ".bin" exists and is newer than xmlFile the ".bin" file will be read directly. Otherwise xmlFile is read and then serialized to xmlFile + ".bin" for use the next time.

Parameters
xmlFile The cacheable mapping file to be added.
Returns
  • this (for method chaining purposes)
Throws
MappingException Indicates problems reading the cached file or processing the non-cached file.

public Configuration addCacheableFile (String xmlFile)

Add a cacheable mapping file.

Parameters
xmlFile The name of the file to be added. This must be in a form useable to simply construct a File instance.
Returns
  • this (for method chaining purposes)
Throws
MappingException Indicates problems reading the cached file or processing the non-cached file.

public Configuration addCacheableFileStrictly (File xmlFile)

INTENDED FOR TESTSUITE USE ONLY!

Much like addCacheableFile(File) except that here we will fail immediately if the cache version cannot be found or used for whatever reason

Parameters
xmlFile The xml file, not the bin!
Returns
  • The dom "deserialized" from the cached file.
Throws
SerializationException Indicates a problem deserializing the cached dom tree
FileNotFoundException Indicates that the cached file was not found or was not usable.

public Configuration addClass (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.

Parameters
persistentClass The mapped class
Returns
  • this (for method chaining purposes)
Throws
MappingException Indicates problems locating the resource or processing the contained mapping document.

public Configuration addDirectory (File dir)

Read all mapping documents from a directory tree.

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

Parameters
dir The directory
Returns
  • this (for method chaining purposes)
Throws
MappingException Indicates problems reading the jar file or processing the contained mapping documents.

public Configuration addDocument (Document doc)

Read mappings from a DOM Document

Parameters
doc The DOM document
Returns
  • this (for method chaining purposes)
Throws
MappingException Indicates problems reading the DOM or processing the mapping document.

public void addFetchProfile (FetchProfile fetchProfile)

public Configuration addFile (File xmlFile)

Read mappings from a particular XML file

Parameters
xmlFile a path to a file
Returns
  • this (for method chaining purposes)
Throws
MappingException Indicates inability to locate the specified mapping file. Historically this could have indicated a problem parsing the XML document, but that is now delayed until after buildMappings()

public Configuration addFile (String xmlFile)

Read mappings from a particular XML file

Parameters
xmlFile a path to a file
Returns
  • this (for method chaining purposes)
Throws
MappingException Indicates inability to locate or parse the specified mapping file.

public void addFilterDefinition (FilterDefinition definition)

public Configuration addInputStream (InputStream xmlInputStream)

Read mappings from an InputStream.

Parameters
xmlInputStream The input stream containing a DOM.
Returns
  • this (for method chaining purposes)
Throws
MappingException Indicates problems reading the stream, or processing the contained mapping document.

public Configuration addJar (File jar)

Read all mappings from a jar file

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

Parameters
jar a jar file
Returns
  • this (for method chaining purposes)
Throws
MappingException Indicates problems reading the jar file or processing the contained mapping documents.

public Configuration addPackage (String packageName)

Read package-level metadata.

Parameters
packageName java package name
Returns
  • this (for method chaining)
Throws
MappingException in case there is an error in the mapping data

public Configuration addProperties (Properties extraProperties)

Add the given properties to ours.

Parameters
extraProperties The properties to add.
Returns
  • this for method chaining

public Configuration addResource (String resourceName)

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

Parameters
resourceName The resource name
Returns
  • this (for method chaining purposes)
Throws
MappingException Indicates problems locating the resource or processing the contained mapping document.

public Configuration addResource (String resourceName, ClassLoader classLoader)

Read mappings as a application resource (i.e. classpath lookup).

Parameters
resourceName The resource name
classLoader The class loader to use.
Returns
  • this (for method chaining purposes)
Throws
MappingException Indicates problems locating the resource or processing the contained mapping document.

public void addSqlFunction (String functionName, SQLFunction function)

public Configuration addURL (URL url)

Read mappings from a URL

Parameters
url The url for the mapping document to be read.
Returns
  • this (for method chaining purposes)
Throws
MappingException Indicates problems reading the URL or processing the mapping document.

public Configuration addXML (String xml)

Read mappings from a String

Parameters
xml an XML string
Returns
  • this (for method chaining purposes)
Throws
MappingException Indicates problems parsing the given XML string

public Mapping buildMapping ()

public void buildMappings ()

Call this to ensure the mappings are fully compiled/built. Usefull to ensure getting access to all information in the metamodel when calling e.g. getClassMappings().

public SessionFactory buildSessionFactory ()

Create a SessionFactory using the properties and mappings in this configuration. The SessionFactory will be immutable, so changes made to this Configuration after building the SessionFactory will not affect it.

Returns
Throws
HibernateException usually indicates an invalid configuration or invalid mapping information

public Settings buildSettings (Properties props)

public Settings buildSettings ()

Create an object-oriented view of the configuration properties

Returns
  • The build settings

public Configuration configure (File configFile)

Use the mappings and properties specified in the given application file. The format of the file is defined in hibernate-configuration-3.0.dtd.

Parameters
configFile File from which you wish to load the configuration
Returns
  • this for method chaining
Throws
HibernateException Generally indicates a problem access the file

public Configuration configure (Document document)

Use the mappings and properties specified in the given XML document. The format of the file is defined in hibernate-configuration-3.0.dtd.

Parameters
document an XML document from which you wish to load the configuration
Returns
  • A configuration configured via the Document
Throws
HibernateException if there is problem in accessing the file.

public Configuration configure (URL url)

Use the mappings and properties specified in the given document. The format of the document is defined in hibernate-configuration-3.0.dtd.

Parameters
url URL from which you wish to load the configuration
Returns
  • this for method chaining
Throws
HibernateException Generally indicates a problem access the url

public Configuration configure ()

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

Returns
  • this for method chaining
Throws
HibernateException Generally indicates we cannot find hibernate.cfg.xml

public Configuration configure (String resource)

Use the mappings and properties specified in the given application resource. The format of the resource is defined in hibernate-configuration-3.0.dtd.

The resource is found via getConfigurationInputStream(String)

Parameters
resource The resource to use
Returns
  • this for method chaining
Throws
HibernateException Generally indicates we cannot find the named resource

public Mappings createMappings ()

Create a new Mappings to add class and collection mappings to.

Returns
  • The created mappings

public String[] generateDropSchemaScript (Dialect dialect)

Generate DDL for dropping tables

Parameters
dialect The dialect for which to generate the drop script
Returns
  • The sequence of DDL commands to drop the schema objects
Throws
HibernateException Generally indicates a problem calling buildMappings()
See Also

public String[] generateSchemaCreationScript (Dialect dialect)

Parameters
dialect The dialect for which to generate the creation script
Returns
  • The sequence of DDL commands to create the schema objects
Throws
HibernateException Generally indicates a problem calling buildMappings()
See Also

public String[] generateSchemaUpdateScript (Dialect dialect, DatabaseMetadata databaseMetadata)

Parameters
dialect The dialect for which to generate the creation script
databaseMetadata The database catalog information for the database to be updated; needed to work out what should be created/altered
Returns
  • The sequence of DDL commands to apply the schema objects
Throws
HibernateException Generally indicates a problem calling buildMappings()
See Also

public PersistentClass getClassMapping (String entityName)

Get the mapping for a particular entity

Parameters
entityName An entity name.
Returns
  • the entity mapping information

public Iterator<PersistentClass> getClassMappings ()

Iterate the entity mappings

Returns
  • Iterator of the entity mappings currently contained in the configuration.

public Collection getCollectionMapping (String role)

Get the mapping for a particular collection role

Parameters
role a collection role
Returns
  • The collection mapping information

public Iterator getCollectionMappings ()

Iterate the collection mappings

Returns
  • Iterator of the collection mappings currently contained in the configuration.

public EntityNotFoundDelegate getEntityNotFoundDelegate ()

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

Returns
  • The user-supplied delegate

public EntityResolver getEntityResolver ()

public EntityTuplizerFactory getEntityTuplizerFactory ()

public EventListeners getEventListeners ()

public Map getFilterDefinitions ()

public DefaultIdentifierGeneratorFactory getIdentifierGeneratorFactory ()

Retrieve the IdentifierGeneratorFactory in effect for this configuration.

Returns
  • This configuration's IdentifierGeneratorFactory.

public Map<StringString> getImports ()

Get the query language imports

Returns
  • a mapping from "import" names to fully qualified class names

public Interceptor getInterceptor ()

Rterieve the configured Interceptor.

Returns

public Iterator<MappedSuperclass> getMappedSuperclassMappings ()

Iterate the mapped super class mappings EXPERIMENTAL Consider this API as PRIVATE

Returns
  • iterator over the MappedSuperclass mapping currently contained in the configuration.

public Map<StringNamedQueryDefinition> getNamedQueries ()

public Map getNamedSQLQueries ()

public NamingStrategy getNamingStrategy ()

public PersisterClassProvider getPersisterClassProvider ()

public Properties getProperties ()

Get all properties

Returns
  • all properties

public String getProperty (String propertyName)

Get a property value by name

Parameters
propertyName The name of the property
Returns
  • The value curently associated with that property name; may be null.

public ReflectionManager getReflectionManager ()

public SessionFactoryObserver getSessionFactoryObserver ()

public Map getSqlFunctions ()

public Map getSqlResultSetMappings ()

public Iterator<Table> getTableMappings ()

Iterate the table mappings

Returns
  • Iterator of the table mappings currently contained in the configuration.

public TypeResolver getTypeResolver ()

public Iterator iterateFetchProfiles ()

public Configuration mergeProperties (Properties 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.

Parameters
properties The properties to merge
Returns
  • this for ethod chaining

public void registerTypeOverride (CompositeUserType type, String[] keys)

public void registerTypeOverride (BasicType type)

Allows registration of a type into the type registry. The phrase 'override' in the method name simply reminds that registration *potentially* replaces a previously registered type .

Parameters
type The type to register.

public void registerTypeOverride (UserType type, String[] keys)

public Configuration setCacheConcurrencyStrategy (String entityName, String concurrencyStrategy)

Set up a cache for an entity class

Parameters
entityName The name of the entity to which we shoudl associate these cache settings
concurrencyStrategy The cache strategy to use
Returns
  • this for method chaining

public Configuration setCacheConcurrencyStrategy (String entityName, String concurrencyStrategy, String region)

Set up a cache for an entity class, giving an explicit region name

Parameters
entityName The name of the entity to which we should associate these cache settings
concurrencyStrategy The cache strategy to use
region The name of the cache region to use
Returns
  • this for method chaining

public void setCacheConcurrencyStrategy (String entityName, String concurrencyStrategy, String region, boolean cacheLazyProperty)

public void setCollectionCacheConcurrencyStrategy (String collectionRole, String concurrencyStrategy, String region)

Set up a cache for a collection role, giving an explicit region name

Parameters
collectionRole The name of the collection to which we should associate these cache settings
concurrencyStrategy The cache strategy to use
region The name of the cache region to use
Returns
  • this for method chaining

public Configuration setCollectionCacheConcurrencyStrategy (String collectionRole, String concurrencyStrategy)

Set up a cache for a collection role

Parameters
collectionRole The name of the collection to which we should associate these cache settings
concurrencyStrategy The cache strategy to use
Returns
  • this for method chaining

public void setEntityNotFoundDelegate (EntityNotFoundDelegate 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...

Parameters
entityNotFoundDelegate The delegate to use

public void setEntityResolver (EntityResolver entityResolver)

Set a custom entity resolver. This entity resolver must be set before addXXX(misc) call. Default value is DTDEntityResolver

Parameters
entityResolver entity resolver to use

public Configuration setInterceptor (Interceptor interceptor)

Set the current Interceptor

Parameters
interceptor The Interceptor to use for the built SessionFactory.
Returns
  • this for method chaining

public void setListener (String type, String listener)

public void setListener (String type, Object listener)

public void setListeners (String type, String[] listenerClasses)

public void setListeners (String type, Object[] listeners)

public Configuration setNamingStrategy (NamingStrategy namingStrategy)

Set a custom naming strategy

Parameters
namingStrategy the NamingStrategy to set
Returns
  • this for method chaining

public Configuration setPersisterClassProvider (PersisterClassProvider persisterClassProvider)

Defines a custom persister class provider. The persister class is chosen according to the following rules in decreasing priority: - the persister class defined explicitly via annotation or XML - the persister class returned by the PersisterClassProvider implementation (if not null) - the default provider as chosen by Hibernate Core (best choice most of the time)

Parameters
persisterClassProvider implementation

public void setPrecedence (String precedence)

public Configuration setProperties (Properties properties)

Specify a completely new set of properties

Parameters
properties The new set of properties
Returns
  • this for method chaining

public Configuration setProperty (String propertyName, String value)

Set a property value by name

Parameters
propertyName The name of the property to set
value The new property value
Returns
  • this for method chaining

public void setSessionFactoryObserver (SessionFactoryObserver sessionFactoryObserver)

public void validateSchema (Dialect dialect, DatabaseMetadata databaseMetadata)

Protected Methods

protected Configuration doConfigure (Document doc)

Parse a dom4j document conforming to the Hibernate Configuration DTD (hibernate-configuration-3.0.dtd) and use its information to configure this Configuration's state

Parameters
doc The dom4j document
Returns
  • this for method chaining
Throws
HibernateException Indicates a problem performing the configuration task

protected Configuration doConfigure (InputStream stream, String resourceName)

Configure this configuration's state from the contents of the given input stream. The expectation is that the stream contents represent an XML document conforming to the Hibernate Configuration DTD. See doConfigure(Document) for further details.

Parameters
stream The input stream from which to read
resourceName The name to use in warning/error messages
Returns
  • this for method chaining
Throws
HibernateException Indicates a problem reading the stream contents.

protected ExtendsQueueEntry findPossibleExtends ()

protected InputStream getConfigurationInputStream (String resource)

Get the configuration file as an InputStream. Might be overridden by subclasses to allow the configuration to be located by some arbitrary mechanism.

By default here we use classpath resource resolution

Parameters
resource The resource to locate
Returns
  • The stream
Throws
HibernateException Generally indicates we cannot find the named resource

protected void reset ()

protected void secondPassCompile ()

protected void secondPassCompileForeignKeys (Table table, Set done)