|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hibernate.cfg.Configuration org.hibernate.cfg.AnnotationConfiguration
public class AnnotationConfiguration
Similar to the Configuration
object but handles EJB3 and Hibernate
specific annotations as a metadata facility.
Nested Class Summary | |
---|---|
protected class |
AnnotationConfiguration.ExtendedMappingsImpl
|
Nested classes/interfaces inherited from class org.hibernate.cfg.Configuration |
---|
Configuration.MappingsImpl |
Field Summary | |
---|---|
static String |
ARTEFACT_PROCESSING_ORDER
|
static ConfigurationArtefactType[] |
DEFAULT_ARTEFACT_PROCESSING_ORDER
|
static String |
DEFAULT_CACHE_CONCURRENCY_STRATEGY
Setting used to give the name of the default CacheConcurrencyStrategy
to use when either @Cacheable or
@Cache is used. |
static String |
USE_NEW_ID_GENERATOR_MAPPINGS
Setting which indicates whether or not the new IdentifierGenerator are used
for AUTO, TABLE and SEQUENCE. |
Fields inherited from class org.hibernate.cfg.Configuration |
---|
auxiliaryDatabaseObjects, classes, collections, columnNameBindingPerTable, extendsQueue, fetchProfiles, filterDefinitions, imports, namedQueries, namedSqlQueries, namingStrategy, propertyReferences, secondPasses, settingsFactory, sqlFunctions, sqlResultSetMappings, tableNameBinding, tables, typeDefs, xmlHelper |
Constructor Summary | |
---|---|
AnnotationConfiguration()
|
|
AnnotationConfiguration(SettingsFactory sf)
|
Method Summary | |
---|---|
void |
add(org.dom4j.Document doc)
|
AnnotationConfiguration |
addAnnotatedClass(Class persistentClass)
Read a mapping from the class annotation metadata (JSR 175). |
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 resouurce 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 |
addInputStream(InputStream xmlInputStream)
Read mappings from an InputStream . |
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)
Set the given properties |
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 |
SessionFactory |
buildSessionFactory()
Instantiate a new SessionFactory, using the properties and mappings in this configuration. |
AnnotationConfiguration |
configure()
Use the mappings and properties specified in an application resource named hibernate.cfg.xml. |
AnnotationConfiguration |
configure(Document document)
Use the mappings and properties specified in the given XML document. |
AnnotationConfiguration |
configure(File configFile)
Use the mappings and properties specified in the given application file. |
AnnotationConfiguration |
configure(String resource)
Use the mappings and properties specified in the given application resource. |
AnnotationConfiguration |
configure(URL url)
Use the mappings and properties specified in the given document. |
ExtendedMappings |
createExtendedMappings()
|
protected AnnotationConfiguration |
doConfigure(org.dom4j.Document doc)
|
protected AnnotationConfiguration |
doConfigure(InputStream stream,
String resourceName)
Use the mappings and properties specified in the given application resource. |
org.hibernate.annotations.common.reflection.ReflectionManager |
getReflectionManager()
|
AnnotationConfiguration |
mergeProperties(Properties properties)
Adds the incoming properties to the internap properties structure, as long as the internal structure does not already contain an entry for the given key. |
protected List<org.hibernate.annotations.common.reflection.XClass> |
orderAndFillHierarchy(List<org.hibernate.annotations.common.reflection.XClass> original)
Takes the list of entities annotated with @Entity or @MappedSuperclass and returns them in an
ordered list. |
protected void |
parseMappingElement(org.dom4j.Element subelement,
String name)
|
protected void |
reset()
|
protected void |
secondPassCompile()
|
AnnotationConfiguration |
setCacheConcurrencyStrategy(String clazz,
String concurrencyStrategy)
Set up a cache for an entity class |
void |
setCacheConcurrencyStrategy(String clazz,
String concurrencyStrategy,
String region,
boolean cacheLazyProperty)
|
AnnotationConfiguration |
setCollectionCacheConcurrencyStrategy(String collectionRole,
String concurrencyStrategy)
Set up a cache for a collection role |
void |
setCollectionCacheConcurrencyStrategy(String collectionRole,
String concurrencyStrategy,
String region)
|
AnnotationConfiguration |
setInterceptor(Interceptor interceptor)
Configure an Interceptor |
AnnotationConfiguration |
setNamingStrategy(NamingStrategy namingStrategy)
Set a custom naming strategy |
void |
setPrecedence(String precedence)
|
AnnotationConfiguration |
setProperties(Properties properties)
Specify a completely new set of properties |
AnnotationConfiguration |
setProperty(String propertyName,
String value)
Set a property |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_CACHE_CONCURRENCY_STRATEGY
CacheConcurrencyStrategy
to use when either @Cacheable
or
@Cache
is used. @Cache(strategy="..")
is used to override.
public static final String USE_NEW_ID_GENERATOR_MAPPINGS
IdentifierGenerator
are used
for AUTO, TABLE and SEQUENCE.
Default to false to keep backward compatibility.
public static final String ARTEFACT_PROCESSING_ORDER
public static final ConfigurationArtefactType[] DEFAULT_ARTEFACT_PROCESSING_ORDER
Constructor Detail |
---|
public AnnotationConfiguration()
public AnnotationConfiguration(SettingsFactory sf)
Method Detail |
---|
protected List<org.hibernate.annotations.common.reflection.XClass> orderAndFillHierarchy(List<org.hibernate.annotations.common.reflection.XClass> original)
@Entity
or @MappedSuperclass
and returns them in an
ordered list.
original
- The list of all entities annotated with @Entity
or @MappedSuperclass
public AnnotationConfiguration addAnnotatedClass(Class persistentClass) throws MappingException
persistentClass
- the mapped class
MappingException
- in case there is a configuration error for the specified classpublic AnnotationConfiguration addPackage(String packageName) throws MappingException
packageName
- java package name
MappingException
- in case there is an error in the mapping datapublic ExtendedMappings createExtendedMappings()
public void setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy, String region, boolean cacheLazyProperty) throws MappingException
MappingException
public void setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy, String region) throws MappingException
setCollectionCacheConcurrencyStrategy
in class Configuration
MappingException
protected void reset()
reset
in class Configuration
protected void secondPassCompile() throws MappingException
secondPassCompile
in class Configuration
MappingException
protected void parseMappingElement(org.dom4j.Element subelement, String name)
parseMappingElement
in class Configuration
public void add(org.dom4j.Document doc) throws MappingException
add
in class Configuration
MappingException
public void setPrecedence(String precedence)
public AnnotationConfiguration addInputStream(InputStream xmlInputStream) throws MappingException
Configuration
InputStream
.
addInputStream
in class Configuration
xmlInputStream
- The input stream containing a DOM.
MappingException
- Indicates problems reading the stream, or
processing the contained mapping document.public SessionFactory buildSessionFactory() throws HibernateException
Configuration
buildSessionFactory
in class Configuration
HibernateException
SessionFactory
public AnnotationConfiguration addFile(String xmlFile) throws MappingException
Configuration
addFile
in class Configuration
xmlFile
- a path to a file
MappingException
- Indicates inability to locate or parse
the specified mapping file.Configuration.addFile(java.io.File)
public AnnotationConfiguration addFile(File xmlFile) throws MappingException
Configuration
addFile
in class Configuration
xmlFile
- a path to a file
MappingException
- Indicates inability to locate or parse
the specified mapping file.public AnnotationConfiguration addCacheableFile(File xmlFile) throws MappingException
Configuration
addCacheableFile
in class Configuration
xmlFile
- The cacheable mapping file to be added.
MappingException
- Indicates problems reading the cached file or processing
the non-cached file.public AnnotationConfiguration addCacheableFile(String xmlFile) throws MappingException
Configuration
addCacheableFile
in class Configuration
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.Configuration.addCacheableFile(java.io.File)
public AnnotationConfiguration addXML(String xml) throws MappingException
Configuration
addXML
in class Configuration
xml
- an XML string
MappingException
- Indicates problems parsing the
given XML stringpublic AnnotationConfiguration addURL(URL url) throws MappingException
Configuration
addURL
in class Configuration
url
- The url for the mapping document to be read.
MappingException
- Indicates problems reading the URL or processing
the mapping document.public AnnotationConfiguration addResource(String resourceName, ClassLoader classLoader) throws MappingException
Configuration
addResource
in class Configuration
resourceName
- The resource nameclassLoader
- The class loader to use.
MappingException
- Indicates problems locating the resource or
processing the contained mapping document.public AnnotationConfiguration addDocument(Document doc) throws MappingException
Configuration
addDocument
in class Configuration
doc
- The DOM document
MappingException
- Indicates problems reading the DOM or processing
the mapping document.public AnnotationConfiguration addResource(String resourceName) throws MappingException
Configuration
addResource
in class Configuration
resourceName
- The resource name
MappingException
- Indicates problems locating the resource or
processing the contained mapping document.public AnnotationConfiguration addClass(Class persistentClass) throws MappingException
Configuration
addClass
in class Configuration
persistentClass
- The mapped class
MappingException
- Indicates problems locating the resource or
processing the contained mapping document.public AnnotationConfiguration addJar(File jar) throws MappingException
Configuration
addJar
in class Configuration
jar
- a jar file
MappingException
- Indicates problems reading the jar file or
processing the contained mapping documents.public AnnotationConfiguration addDirectory(File dir) throws MappingException
Configuration
addDirectory
in class Configuration
dir
- The directory
MappingException
- Indicates problems reading the jar file or
processing the contained mapping documents.public AnnotationConfiguration setInterceptor(Interceptor interceptor)
Configuration
setInterceptor
in class Configuration
public AnnotationConfiguration setProperties(Properties properties)
Configuration
setProperties
in class Configuration
public AnnotationConfiguration addProperties(Properties extraProperties)
Configuration
addProperties
in class Configuration
public AnnotationConfiguration mergeProperties(Properties properties)
Configuration
mergeProperties
in class Configuration
public AnnotationConfiguration setProperty(String propertyName, String value)
Configuration
setProperty
in class Configuration
public AnnotationConfiguration configure() throws HibernateException
Configuration
configure
in class Configuration
HibernateException
public AnnotationConfiguration configure(String resource) throws HibernateException
Configuration
configure
in class Configuration
HibernateException
public AnnotationConfiguration configure(URL url) throws HibernateException
Configuration
configure
in class Configuration
url
- URL from which you wish to load the configuration
HibernateException
public AnnotationConfiguration configure(File configFile) throws HibernateException
Configuration
configure
in class Configuration
configFile
- File from which you wish to load the configuration
HibernateException
protected AnnotationConfiguration doConfigure(InputStream stream, String resourceName) throws HibernateException
Configuration
doConfigure
in class Configuration
stream
- Inputstream to be read fromresourceName
- The name to use in warning/error messages
HibernateException
public AnnotationConfiguration configure(Document document) throws HibernateException
Configuration
configure
in class Configuration
document
- an XML document from which you wish to load the configuration
HibernateException
- if there is problem in accessing the file.protected AnnotationConfiguration doConfigure(org.dom4j.Document doc) throws HibernateException
doConfigure
in class Configuration
HibernateException
public AnnotationConfiguration setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy) throws MappingException
Configuration
setCacheConcurrencyStrategy
in class Configuration
MappingException
public AnnotationConfiguration setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy) throws MappingException
Configuration
setCollectionCacheConcurrencyStrategy
in class Configuration
MappingException
public AnnotationConfiguration setNamingStrategy(NamingStrategy namingStrategy)
Configuration
setNamingStrategy
in class Configuration
namingStrategy
- the NamingStrategy to setpublic org.hibernate.annotations.common.reflection.ReflectionManager getReflectionManager()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |