public class

AnnotationConfiguration

extends Configuration
java.lang.Object
   ↳ org.hibernate.cfg.Configuration
     ↳ org.hibernate.cfg.AnnotationConfiguration

This class is deprecated.
All functionality has been moved to Configuration

Class Overview

Similar to the Configuration object but handles EJB3 and Hibernate specific annotations as a metadata facility.

Summary

Nested Classes
class AnnotationConfiguration.ExtendedMappingsImpl  
[Expand]
Inherited Constants
From class org.hibernate.cfg.Configuration
[Expand]
Inherited Fields
From class org.hibernate.cfg.Configuration
Public Constructors
AnnotationConfiguration()
AnnotationConfiguration(SettingsFactory sf)
Public Methods
AnnotationConfiguration addAnnotatedClass(Class annotatedClass)
Read metadata from the annotations associated with this class.
AnnotationConfiguration addCacheableFile(File xmlFile)
Add a cached mapping file.
AnnotationConfiguration addCacheableFile(String xmlFile)
Add a cacheable mapping file.
AnnotationConfiguration 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.
AnnotationConfiguration addDirectory(File dir)
Read all mapping documents from a directory tree.
AnnotationConfiguration addDocument(Document doc)
Read mappings from a DOM Document
AnnotationConfiguration addFile(File xmlFile)
Read mappings from a particular XML file
AnnotationConfiguration addFile(String xmlFile)
Read mappings from a particular XML file
AnnotationConfiguration addJar(File jar)
Read all mappings from a jar file

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

AnnotationConfiguration addPackage(String packageName)
Read package-level metadata.
AnnotationConfiguration addProperties(Properties extraProperties)
Add the given properties to ours.
AnnotationConfiguration addResource(String resourceName)
Read mappings as a application resourceName (i.e.
AnnotationConfiguration addResource(String resourceName, ClassLoader classLoader)
Read mappings as a application resource (i.e.
AnnotationConfiguration addURL(URL url)
Read mappings from a URL
AnnotationConfiguration addXML(String xml)
Read mappings from a String
AnnotationConfiguration configure(File configFile)
Use the mappings and properties specified in the given application file.
AnnotationConfiguration configure(Document document)
Use the mappings and properties specified in the given XML document.
AnnotationConfiguration configure(URL url)
Use the mappings and properties specified in the given document.
AnnotationConfiguration configure(String resource)
Use the mappings and properties specified in the given application resource.
AnnotationConfiguration configure()
Use the mappings and properties specified in an application resource named hibernate.cfg.xml.
ExtendedMappings createExtendedMappings()
AnnotationConfiguration 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.
AnnotationConfiguration setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy)
Set up a cache for an entity class
AnnotationConfiguration setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy, String region)
Set up a cache for an entity class, giving an explicit region name
AnnotationConfiguration setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy)
Set up a cache for a collection role
AnnotationConfiguration setInterceptor(Interceptor interceptor)
Set the current Interceptor
AnnotationConfiguration setNamingStrategy(NamingStrategy namingStrategy)
Set a custom naming strategy
AnnotationConfiguration setPersisterClassProvider(PersisterClassProvider persisterClassProvider)
Defines a custom persister class provider.
AnnotationConfiguration setProperties(Properties properties)
Specify a completely new set of properties
AnnotationConfiguration setProperty(String propertyName, String value)
Set a property value by name
Protected Methods
AnnotationConfiguration 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
AnnotationConfiguration doConfigure(InputStream stream, String resourceName)
Configure this configuration's state from the contents of the given input stream.
[Expand]
Inherited Methods
From class org.hibernate.cfg.Configuration
From class java.lang.Object

Public Constructors

public AnnotationConfiguration ()

public AnnotationConfiguration (SettingsFactory sf)

Public Methods

public AnnotationConfiguration addAnnotatedClass (Class annotatedClass)

Read metadata from the annotations associated with this class.

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

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

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

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

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

public AnnotationConfiguration addDocument (Document doc)

Read mappings from a DOM Document

Parameters
doc The DOM document
Returns
  • this (for method chaining purposes)

public AnnotationConfiguration addFile (File xmlFile)

Read mappings from a particular XML file

Parameters
xmlFile a path to a file
Returns
  • this (for method chaining purposes)

public AnnotationConfiguration addFile (String xmlFile)

Read mappings from a particular XML file

Parameters
xmlFile a path to a file
Returns
  • this (for method chaining purposes)

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

public AnnotationConfiguration addPackage (String packageName)

Read package-level metadata.

Parameters
packageName java package name
Returns
  • this (for method chaining)

public AnnotationConfiguration addProperties (Properties extraProperties)

Add the given properties to ours.

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

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

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

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

public AnnotationConfiguration addXML (String xml)

Read mappings from a String

Parameters
xml an XML string
Returns
  • this (for method chaining purposes)

public AnnotationConfiguration 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

public AnnotationConfiguration 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

public AnnotationConfiguration 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

public AnnotationConfiguration 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

public AnnotationConfiguration configure ()

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

Returns
  • this for method chaining

public ExtendedMappings createExtendedMappings ()

public AnnotationConfiguration 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 AnnotationConfiguration setCacheConcurrencyStrategy (String clazz, String concurrencyStrategy)

Set up a cache for an entity class

Parameters
clazz 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 AnnotationConfiguration setCacheConcurrencyStrategy (String clazz, String concurrencyStrategy, String region)

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

Parameters
clazz 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 AnnotationConfiguration 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 AnnotationConfiguration setInterceptor (Interceptor interceptor)

Set the current Interceptor

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

public AnnotationConfiguration setNamingStrategy (NamingStrategy namingStrategy)

Set a custom naming strategy

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

public AnnotationConfiguration 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 AnnotationConfiguration setProperties (Properties properties)

Specify a completely new set of properties

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

public AnnotationConfiguration 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

Protected Methods

protected AnnotationConfiguration 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

protected AnnotationConfiguration 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