Top Description Inners Fields Constructors Methods
org.hibernate.cfg

public Class Configuration

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
org.hibernate.cfg.AnnotationConfiguration
Imports
java.io.File, .FileInputStream, .FileNotFoundException, .FileOutputStream, .IOException, .InputStream, .ObjectInputStream, .Serializable, .StringReader, java.lang.reflect.Array, .Constructor, .InvocationTargetException, .Method, java.net.URL, java.util.ArrayList, .Arrays, .Collections, .Enumeration, .HashMap, .HashSet, .Iterator, .LinkedHashMap, .List, .ListIterator, .Map, .Properties, .ResourceBundle, .Set, .StringTokenizer, .TreeMap, java.util.jar.JarFile, java.util.zip.ZipEntry, javax.persistence.Embeddable, .Entity, .MapsId, org.dom4j.Attribute, .Document, .DocumentException, .Element, org.slf4j.Logger, .LoggerFactory, org.xml.sax.EntityResolver, .InputSource, org.hibernate.AnnotationException, .DuplicateMappingException, .EmptyInterceptor, .HibernateException, .Interceptor, .InvalidMappingException, .MappingException, .MappingNotFoundException, .SessionFactory, .SessionFactoryObserver, org.hibernate.annotations.AnyMetaDef, org.hibernate.annotations.common.reflection.MetadataProvider, .MetadataProviderInjector, .ReflectionManager, .XClass, org.hibernate.annotations.common.reflection.java.JavaReflectionManager, org.hibernate.cfg.annotations.reflection.JPAMetadataProvider, org.hibernate.cfg.beanvalidation.BeanValidationActivator, org.hibernate.dialect.Dialect, .MySQLDialect, org.hibernate.dialect.function.SQLFunction, org.hibernate.engine.FilterDefinition, .Mapping, .NamedQueryDefinition, .NamedSQLQueryDefinition, .ResultSetMappingDefinition, org.hibernate.event.AutoFlushEventListener, .DeleteEventListener, .DirtyCheckEventListener, .EventListeners, .EvictEventListener, .FlushEntityEventListener, .FlushEventListener, .InitializeCollectionEventListener, .LoadEventListener, .LockEventListener, .MergeEventListener, .PersistEventListener, .PostCollectionRecreateEventListener, .PostCollectionRemoveEventListener, .PostCollectionUpdateEventListener, .PostDeleteEventListener, .PostInsertEventListener, .PostLoadEventListener, .PostUpdateEventListener, .PreCollectionRecreateEventListener, .PreCollectionRemoveEventListener, .PreCollectionUpdateEventListener, .PreDeleteEventListener, .PreInsertEventListener, .PreLoadEventListener, .PreUpdateEventListener, .RefreshEventListener, .ReplicateEventListener, .SaveOrUpdateEventListener, org.hibernate.id.IdentifierGenerator, .IdentifierGeneratorAggregator, .PersistentIdentifierGenerator, org.hibernate.id.factory.DefaultIdentifierGeneratorFactory, .IdentifierGeneratorFactory, org.hibernate.impl.SessionFactoryImpl, org.hibernate.mapping.AuxiliaryDatabaseObject, .Collection, .Column, .DenormalizedTable, .FetchProfile, .ForeignKey, .IdGenerator, .IdentifierCollection, .Index, .Join, .MappedSuperclass, .MetadataSource, .PersistentClass, .Property, .RootClass, .SimpleValue, .Table, .TypeDef, .UniqueKey, org.hibernate.persister.PersisterClassProvider, org.hibernate.proxy.EntityNotFoundDelegate, org.hibernate.secure.JACCConfiguration, org.hibernate.tool.hbm2ddl.DatabaseMetadata, .IndexMetadata, .TableMetadata, org.hibernate.tuple.entity.EntityTuplizerFactory, org.hibernate.type.BasicType, .SerializationException, .Type, .TypeResolver, org.hibernate.usertype.CompositeUserType, .UserType, org.hibernate.util.ArrayHelper, .CollectionHelper, .ConfigHelper, .JoinedIterator, .PropertiesHelper, .ReflectHelper, .SerializationHelper, .StringHelper, .XMLHelper, org.hibernate.util.xml.MappingReader, .Origin, .OriginImpl, .XmlDocument, .XmlDocumentImpl

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.
Author
Gavin King
See Also
org.hibernate.SessionFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
protected class
Configuration.MappingsImpl

Deprecated as a consequence of ExtendedMappings being deprecated.
Internal implementation of the Mappings interface giving access to the Configuration's internal metadata repository state (Configuration#classes, Configuration#tables, etc).
protected class
pack-priv class

Field Summary

Modifier and TypeField and Description
private Map<String, AnyMetaDef>
public static final String
protected List<AuxiliaryDatabaseObject>
private List<Configuration.CacheHolder>
protected Map<String, PersistentClass>
private Map<String, AnnotatedClassType>
protected Map<String, Collection>
protected Map<K, V>
public static final MetadataSourceType[]
public static final String
DEFAULT_CACHE_CONCURRENCY_STRATEGY

Setting used to give the name of the default org.hibernate.annotations.CacheConcurrencyStrategy to use when either @Cacheable or @Cache is used.

private Set<String>
private Set<String>
private Set<String>
private Set<String>
private EntityNotFoundDelegate
private EntityResolver
private EntityTuplizerFactory
private EventListeners
protected Map<ExtendsQueueEntry, ?>
protected Map<String, FetchProfile>
protected Map<String, FilterDefinition>
private Map<String, Properties>
private DefaultIdentifierGeneratorFactory
protected Map<String, String>
private boolean
private Interceptor
private boolean
private boolean
private Map<String, Map<String, Join>>
private static final String
private static Logger
private Map<String, String>
private Map<Class<?>, MappedSuperclass>
private transient Mapping
private List<MetadataSourceType>
protected Configuration.MetadataSourceQueue
private Map<String, IdGenerator>
protected Map<String, NamedQueryDefinition>
protected Map<String, NamedSQLQueryDefinition>
protected NamingStrategy
pack-priv final ObjectNameNormalizer
private PersisterClassProvider
private Properties
private Map<XClass, Map<String, PropertyData>>
private Map<XClass, Map<String, PropertyData>>
protected List<Mappings.PropertyReference>
private Map<String, String>
private transient ReflectionManager
private static final String
private static final String
SEARCH_STARTUP_CLASS

Class name of the class needed to enable Search.

private static final String
SEARCH_STARTUP_METHOD

Method to call to enable Search.

protected List<SecondPass>
private SessionFactoryObserver
protected final SettingsFactory
private boolean
protected Map<String, SQLFunction>
protected Map<String, ResultSetMappingDefinition>
protected Map<K, V>
protected Map<String, Table>
protected Map<String, TypeDef>
private TypeResolver
private Map<Table, List<UniqueConstraintHolder>>
public static final String
USE_NEW_ID_GENERATOR_MAPPINGS

Setting which indicates whether or not the new org.hibernate.id.IdentifierGenerator are used for AUTO, TABLE and SEQUENCE.

protected transient XMLHelper

Constructor Summary

AccessConstructor and Description
protected
Configuration(SettingsFactory settingsFactory)

public

Method Summary

Modifier and TypeMethod and Description
private XmlDocument
add(InputSource inputSource, String originType, String originName)

private XmlDocument
add(InputSource inputSource, Origin origin)

public void
add(XmlDocument metadataXml)

private XmlDocument
add(InputStream inputStream, final String type, final String name)

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
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
)

Read mappings from a DOM Document

public void
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
(final File
a path to a file
xmlFile
)

Read mappings from a particular XML file

public void
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.
extraProperties
)

Add the given properties to ours.

private void
public Configuration

Returns:

this (for method chaining purposes)
addResource
(String
The resource name
resourceName
,
ClassLoader
The class loader to use.
classLoader
)

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

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

Returns:

this (for method chaining purposes)
addXML
(String
an XML string
xml
)

Read mappings from a String

private void
private void
private void
private void
private void
public Mapping
public void
buildMappings()

Call this to ensure the mappings are fully compiled/built.

private void
buildRecursiveOrderedFkSecondPasses(List<FkSecondPass>
The list containing the FkSecondPass instances ready for processing.
orderedFkSecondPasses
,
Map<String, Set<FkSecondPass>>
Our lookup data structure to determine dependencies between tables
isADependencyOf
,
String
Table name to start recursive algorithm.
startTable
,
String
The current table name used to check for 'new' dependencies.
currentTable
)

Recursively builds a list of FkSecondPass instances ready to be processed in this order.

public SessionFactory

Returns:

The build SessionFactory
buildSessionFactory
()

Create a SessionFactory using the properties and mappings in this configuration.

public Settings

Returns:

The build settings
buildSettings
()

Create an object-oriented view of the configuration properties

public Settings
private Settings
private void
buildUniqueKeyFromColumnNames(Table table, String keyName, String[] columnNames)

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

Returns:

A configuration configured via the Document
configure
(Document
an XML document from which you wish to load the configuration
document
)

Use the mappings and properties specified in the given XML document.

public Mappings

Returns:

The created mappings
createMappings
()

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

private void
private void
private File
private List<MetadataSourceType>
protected Configuration

Returns:

this for method chaining
doConfigure
(InputStream
The input stream from which to read
stream
,
String
The name to use in warning/error messages
resourceName
)

Configure this configuration's state from the contents of the given input stream.

protected Configuration

Returns:

this for method chaining
doConfigure
(Document
The dom4j 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

private void
private void
enableHibernateSearch()

Tries to automatically register Hibernate Search event listeners by locating the appropriate bootstrap class and calling the enableHibernateSearch method.

private void
protected ExtendsQueueEntry
public String[]

Returns:

The sequence of DDL commands to drop the schema objects
generateDropSchemaScript
(Dialect
The dialect for which to generate the drop script
dialect
)

Generate DDL for dropping tables

public String[]

Returns:

The sequence of DDL commands to create the schema objects
generateSchemaCreationScript
(Dialect
The dialect for which to generate the creation script
dialect
)

public String[]

Returns:

The sequence of DDL commands to apply the schema objects
generateSchemaUpdateScript
(Dialect
The dialect for which to generate the creation script
dialect
,
DatabaseMetadata
The database catalog information for the database to be updated; needed to work out what should be created/altered
databaseMetadata
)

public PersistentClass

Returns:

the entity mapping information
getClassMapping
(String
An entity name.
entityName
)

Get the mapping for a particular entity

public Iterator<PersistentClass>

Returns:

Iterator of the entity mappings currently contained in the configuration.
getClassMappings
()

Iterate the entity mappings

public Collection

Returns:

The collection mapping information
getCollectionMapping
(String
a collection role
role
)

Get the mapping for a particular collection role

public Iterator<E>

Returns:

Iterator of the collection mappings currently contained in the configuration.
getCollectionMappings
()

Iterate the collection mappings

protected InputStream

Returns:

The stream
getConfigurationInputStream
(String
The resource to locate
resource
)

Get the configuration file as an InputStream.

public EntityNotFoundDelegate

Returns:

The user-supplied delegate
getEntityNotFoundDelegate
()

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

public EntityResolver
public EntityTuplizerFactory
public EventListeners
public Map<K, V>
private List<FkSecondPass>

Returns:

Returns a list of all secondPasses instances which are a instance of FkSecondPass.
getFKSecondPassesOnly
()

public DefaultIdentifierGeneratorFactory

Returns:

This configuration's IdentifierGeneratorFactory.
getIdentifierGeneratorFactory
()

Retrieve the IdentifierGeneratorFactory in effect for this configuration.

public Map<String, String>

Returns:

a mapping from "import" names to fully qualified class names
getImports
()

Get the query language imports

private EventListeners
public Interceptor

Returns:

The current Interceptor
getInterceptor
()

Rterieve the configured Interceptor.

public Iterator<MappedSuperclass>

Returns:

iterator over the MappedSuperclass mapping currently contained in the configuration.
getMappedSuperclassMappings
()

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

public Map<String, NamedQueryDefinition>
public Map<K, V>
public NamingStrategy
public PersisterClassProvider
public Properties

Returns:

all properties
getProperties
()

Get all properties

public String

Returns:

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

Get a property value by name

public ReflectionManager
pack-priv RootClass
public SessionFactoryObserver
public Map<K, V>
public Map<K, V>
public Iterator<Table>

Returns:

Iterator of the table mappings currently contained in the configuration.
getTableMappings
()

Iterate the table mappings

public TypeResolver
private static boolean
isOrmXml(XmlDocument xmlDocument)

public Iterator<E>
private Iterator<IdentifierGenerator>
public Configuration

Returns:

this for ethod 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.

private void
private void
private void
private void
parseMappingElement(Element mappingElement, String name)

private List<MetadataSourceType>
private void
private void
private void
processEndOfQueue(List<FkSecondPass> endOfQueueFkSecondPasses)

private int
private void
processFkSecondPassInOrder()

Processes FKSecondPass instances trying to resolve any graph circularity (ie PK made of a many to one linking to an entity having a PK made of a ManyToOne ...).

private void
private void
public void
registerTypeOverride(BasicType
The type to register.
type
)

Allows registration of a type into the type registry.

public void
public void
protected void
protected void
protected void
public Configuration

Returns:

this for method chaining
setCacheConcurrencyStrategy
(String
The name of the entity to which we shoudl associate these cache settings
entityName
,
String
The cache strategy to use
concurrencyStrategy
)

Set up a cache for an entity class

public Configuration

Returns:

this for method chaining
setCacheConcurrencyStrategy
(String
The name of the entity to which we should associate these cache settings
entityName
,
String
The cache strategy to use
concurrencyStrategy
,
String
The name of the cache region to use
region
)

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

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

public Configuration

Returns:

this for method chaining
setCollectionCacheConcurrencyStrategy
(String
The name of the collection to which we should associate these cache settings
collectionRole
,
String
The cache strategy to use
concurrencyStrategy
)

Set up a cache for a collection role

public void

Returns:

this for method chaining
setCollectionCacheConcurrencyStrategy
(String
The name of the collection to which we should associate these cache settings
collectionRole
,
String
The cache strategy to use
concurrencyStrategy
,
String
The name of the cache region to use
region
)

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

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
setEntityResolver(EntityResolver
entity resolver to use
entityResolver
)

Set a custom entity resolver.

public Configuration

Returns:

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

Set the current Interceptor

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

Returns:

this for method chaining
setNamingStrategy
(NamingStrategy
the NamingStrategy to set
namingStrategy
)

Set a custom naming strategy

public Configuration
setPersisterClassProvider(PersisterClassProvider
implementation
persisterClassProvider
)

Defines a custom persister class provider.

public void
setPrecedence(String precedence)

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
private void
public void
validateSchema(Dialect dialect, DatabaseMetadata databaseMetadata)

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait