java.lang.Object | |
↳ | org.hibernate.cfg.Configuration |
Known Direct Subclasses |
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.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Configuration.MappingsImpl | Internal implementation of the Mappings interface giving access to the Configuration's internal
metadata repository state (classes , tables , etc). |
||||||||||
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. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Read metadata from the annotations associated with this class.
| |||||||||||
Add a cached mapping file.
| |||||||||||
Add a cacheable mapping file.
| |||||||||||
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 | |||||||||||
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.
| |||||||||||
Read all mapping documents from a directory tree.
| |||||||||||
Read mappings from a DOM Document
| |||||||||||
Read mappings from a particular XML file
| |||||||||||
Read mappings from a particular XML file
| |||||||||||
Read mappings from an
InputStream . | |||||||||||
Read all mappings from a jar file
Assumes that any file named *.hbm.xml is a mapping document.
| |||||||||||
Read package-level metadata.
| |||||||||||
Add the given properties to ours.
| |||||||||||
Read mappings as a application resourceName (i.e.
| |||||||||||
Read mappings as a application resource (i.e.
| |||||||||||
Read mappings from a URL
| |||||||||||
Read mappings from a String
| |||||||||||
Call this to ensure the mappings are fully compiled/built.
| |||||||||||
Create a
SessionFactory using the properties and mappings in this configuration. | |||||||||||
Create an object-oriented view of the configuration properties
| |||||||||||
Use the mappings and properties specified in the given application file.
| |||||||||||
Use the mappings and properties specified in the given XML document.
| |||||||||||
Use the mappings and properties specified in the given document.
| |||||||||||
Use the mappings and properties specified in an application resource named hibernate.cfg.xml.
| |||||||||||
Use the mappings and properties specified in the given application resource.
| |||||||||||
Create a new Mappings to add class and collection mappings to.
| |||||||||||
Generate DDL for dropping tables
| |||||||||||
Get the mapping for a particular entity
| |||||||||||
Iterate the entity mappings
| |||||||||||
Get the mapping for a particular collection role
| |||||||||||
Iterate the collection mappings
| |||||||||||
Retrieve the user-supplied delegate to handle non-existent entity
scenarios.
| |||||||||||
Retrieve the IdentifierGeneratorFactory in effect for this configuration.
| |||||||||||
Get the query language imports
| |||||||||||
Rterieve the configured
Interceptor . | |||||||||||
Iterate the mapped super class mappings
EXPERIMENTAL Consider this API as PRIVATE
| |||||||||||
Get all properties
| |||||||||||
Get a property value by name
| |||||||||||
Iterate the table mappings
| |||||||||||
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.
| |||||||||||
Allows registration of a type into the type registry.
| |||||||||||
Set up a cache for an entity class
| |||||||||||
Set up a cache for an entity class, giving an explicit region name
| |||||||||||
Set up a cache for a collection role, giving an explicit region name
| |||||||||||
Set up a cache for a collection role
| |||||||||||
Specify a user-supplied delegate to be used to handle scenarios where an entity could not be
located by specified id.
| |||||||||||
Set a custom entity resolver.
| |||||||||||
Set the current
Interceptor | |||||||||||
Set a custom naming strategy
| |||||||||||
Defines a custom persister class provider.
| |||||||||||
Specify a completely new set of properties
| |||||||||||
Set a property value by name
| |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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 | |||||||||||
Configure this configuration's state from the contents of the given input stream.
| |||||||||||
Get the configuration file as an InputStream.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
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.
Setting which indicates whether or not the new IdentifierGenerator
are used
for AUTO, TABLE and SEQUENCE.
Default to false to keep backward compatibility.
Read metadata from the annotations associated with this class.
annotatedClass | The class containing annotations |
---|
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.xmlFile | The cacheable mapping file to be added. |
---|
MappingException | Indicates problems reading the cached file or processing the non-cached file. |
---|
Add a cacheable mapping file.
xmlFile | The name of the file to be added. This must be in a form
useable to simply construct a File instance. |
---|
MappingException | Indicates problems reading the cached file or processing the non-cached file. |
---|
INTENDED FOR TESTSUITE USE ONLY!
Much likeaddCacheableFile(File)
except that here we will fail immediately if
the cache version cannot be found or used for whatever reasonxmlFile | The xml file, not the bin! |
---|
SerializationException | Indicates a problem deserializing the cached dom tree |
---|---|
FileNotFoundException | Indicates that the cached file was not found or was not usable. |
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.
persistentClass | The mapped class |
---|
MappingException | Indicates problems locating the resource or processing the contained mapping document. |
---|
Read all mapping documents from a directory tree.
Assumes that any file named *.hbm.xml is a mapping document.dir | The directory |
---|
MappingException | Indicates problems reading the jar file or processing the contained mapping documents. |
---|
Read mappings from a DOM Document
doc | The DOM document |
---|
MappingException | Indicates problems reading the DOM or processing the mapping document. |
---|
Read mappings from a particular XML file
xmlFile | a path to a file |
---|
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()
|
---|
Read mappings from a particular XML file
xmlFile | a path to a file |
---|
MappingException | Indicates inability to locate or parse the specified mapping file. |
---|
Read mappings from an InputStream
.
xmlInputStream | The input stream containing a DOM. |
---|
MappingException | Indicates problems reading the stream, or processing the contained mapping document. |
---|
Read all mappings from a jar file
Assumes that any file named *.hbm.xml is a mapping document.jar | a jar file |
---|
MappingException | Indicates problems reading the jar file or processing the contained mapping documents. |
---|
Read package-level metadata.
packageName | java package name |
---|
MappingException | in case there is an error in the mapping data |
---|
Add the given properties to ours.
extraProperties | The properties to add. |
---|
Read mappings as a application resourceName (i.e. classpath lookup) trying different class loaders.
resourceName | The resource name |
---|
MappingException | Indicates problems locating the resource or processing the contained mapping document. |
---|
Read mappings as a application resource (i.e. classpath lookup).
resourceName | The resource name |
---|---|
classLoader | The class loader to use. |
MappingException | Indicates problems locating the resource or processing the contained mapping document. |
---|
Read mappings from a URL
url | The url for the mapping document to be read. |
---|
MappingException | Indicates problems reading the URL or processing the mapping document. |
---|
Read mappings from a String
xml | an XML string |
---|
MappingException | Indicates problems parsing the given XML string |
---|
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().
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.
SessionFactory
HibernateException | usually indicates an invalid configuration or invalid mapping information |
---|
Create an object-oriented view of the configuration properties
Use the mappings and properties specified in the given application file. The format of the file is defined in hibernate-configuration-3.0.dtd.
configFile | File from which you wish to load the configuration |
---|
HibernateException | Generally indicates a problem access the file |
---|
Use the mappings and properties specified in the given XML document. The format of the file is defined in hibernate-configuration-3.0.dtd.
document | an XML document from which you wish to load the configuration |
---|
HibernateException | if there is problem in accessing the file. |
---|
Use the mappings and properties specified in the given document. The format of the document is defined in hibernate-configuration-3.0.dtd.
url | URL from which you wish to load the configuration |
---|
HibernateException | Generally indicates a problem access the url |
---|
Use the mappings and properties specified in an application resource named hibernate.cfg.xml.
HibernateException | Generally indicates we cannot find hibernate.cfg.xml |
---|
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 viagetConfigurationInputStream(String)
resource | The resource to use |
---|
HibernateException | Generally indicates we cannot find the named resource |
---|
Create a new Mappings to add class and collection mappings to.
Generate DDL for dropping tables
dialect | The dialect for which to generate the drop script |
---|
HibernateException | Generally indicates a problem calling buildMappings() |
---|
dialect | The dialect for which to generate the creation script |
---|
HibernateException | Generally indicates a problem calling buildMappings() |
---|
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 |
HibernateException | Generally indicates a problem calling buildMappings() |
---|
Get the mapping for a particular entity
entityName | An entity name. |
---|
Iterate the entity mappings
Get the mapping for a particular collection role
role | a collection role |
---|
Iterate the collection mappings
Retrieve the user-supplied delegate to handle non-existent entity scenarios. May be null.
Retrieve the IdentifierGeneratorFactory in effect for this configuration.
Get the query language imports
Rterieve the configured Interceptor
.
Interceptor
Iterate the mapped super class mappings EXPERIMENTAL Consider this API as PRIVATE
Get a property value by name
propertyName | The name of the property |
---|
Iterate the table mappings
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.
properties | The properties to merge |
---|
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 .
type | The type to register. |
---|
Set up a cache for an entity class
entityName | The name of the entity to which we shoudl associate these cache settings |
---|---|
concurrencyStrategy | The cache strategy to use |
Set up a cache for an entity class, giving an explicit region name
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 |
MappingException |
---|
Set up a cache for a collection role, giving an explicit region name
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 |
Set up a cache for a collection role
collectionRole | The name of the collection to which we should associate these cache settings |
---|---|
concurrencyStrategy | The cache strategy to use |
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...
entityNotFoundDelegate | The delegate to use |
---|
Set a custom entity resolver. This entity resolver must be
set before addXXX(misc) call.
Default value is DTDEntityResolver
entityResolver | entity resolver to use |
---|
Set the current Interceptor
interceptor | The Interceptor to use for the built
SessionFactory . |
---|
Set a custom naming strategy
namingStrategy | the NamingStrategy to set |
---|
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)
persisterClassProvider | implementation |
---|
Specify a completely new set of properties
properties | The new set of properties |
---|
Set a property value by name
propertyName | The name of the property to set |
---|---|
value | The new property value |
HibernateException |
---|
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
doc | The dom4j document |
---|
HibernateException | Indicates a problem performing the configuration task |
---|
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.
stream | The input stream from which to read |
---|---|
resourceName | The name to use in warning/error messages |
HibernateException | Indicates a problem reading the stream contents. |
---|
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 resolutionresource | The resource to locate |
---|
HibernateException | Generally indicates we cannot find the named resource |
---|