|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hibernate.cfg.Configuration
public class Configuration
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.
SessionFactory
,
Serialized FormField Summary | |
---|---|
protected List |
auxiliaryDatabaseObjects
|
protected Map |
classes
|
protected Map |
collections
|
protected Map |
columnNameBindingPerTable
|
protected Map |
extendsQueue
|
protected Map |
filterDefinitions
|
protected Map |
imports
|
protected Map |
namedQueries
|
protected Map |
namedSqlQueries
|
protected NamingStrategy |
namingStrategy
|
protected List |
propertyReferences
|
protected List |
secondPasses
|
protected SettingsFactory |
settingsFactory
|
protected Map |
sqlFunctions
|
protected Map |
sqlResultSetMappings
Map |
protected Map |
tableNameBinding
|
protected Map |
tables
|
protected Map |
typeDefs
|
protected XMLHelper |
xmlHelper
|
Constructor Summary | |
---|---|
|
Configuration()
|
protected |
Configuration(SettingsFactory settingsFactory)
|
Method Summary | |
---|---|
protected void |
add(org.dom4j.Document doc)
|
void |
addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject object)
|
Configuration |
addCacheableFile(File xmlFile)
Add a cached mapping file. |
Configuration |
addCacheableFile(String xmlFile)
Add a cacheable mapping file. |
Configuration |
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. |
Configuration |
addDirectory(File dir)
Read all mapping documents from a directory tree. |
Configuration |
addDocument(Document doc)
Read mappings from a DOM Document |
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 |
addProperties(Properties extraProperties)
Set the given properties |
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()
Instantiate a new SessionFactory, using the properties and mappings in this configuration. |
Settings |
buildSettings()
Create an object-oriented view of the configuration properties |
Settings |
buildSettings(Properties props)
|
Configuration |
configure()
Use the mappings and properties specified in an application resource named hibernate.cfg.xml. |
Configuration |
configure(Document document)
Use the mappings and properties specified in the given XML document. |
Configuration |
configure(File configFile)
Use the mappings and properties specified in the given application file. |
Configuration |
configure(String resource)
Use the mappings and properties specified in the given application resource. |
Configuration |
configure(URL url)
Use the mappings and properties specified in the given document. |
Mappings |
createMappings()
Create a new Mappings to add class and collection mappings to. |
protected Configuration |
doConfigure(org.dom4j.Document doc)
|
protected Configuration |
doConfigure(InputStream stream,
String resourceName)
Use the mappings and properties specified in the given application resource. |
protected org.dom4j.Document |
findPossibleExtends()
Find the first possible element in the queue of extends. |
String[] |
generateDropSchemaScript(Dialect dialect)
Generate DDL for dropping tables |
String[] |
generateSchemaCreationScript(Dialect dialect)
Generate DDL for creating tables |
String[] |
generateSchemaUpdateScript(Dialect dialect,
DatabaseMetadata databaseMetadata)
Generate DDL for altering tables |
PersistentClass |
getClassMapping(String entityName)
Get the mapping for a particular entity |
Iterator |
getClassMappings()
Iterate the entity mappings |
Collection |
getCollectionMapping(String role)
Get the mapping for a particular collection role |
Iterator |
getCollectionMappings()
Iterate the collection mappings |
protected InputStream |
getConfigurationInputStream(String resource)
Get the configuration file as an InputStream. |
EntityNotFoundDelegate |
getEntityNotFoundDelegate()
Retrieve the user-supplied delegate to handle non-existent entity scenarios. |
EntityResolver |
getEntityResolver()
|
EntityTuplizerFactory |
getEntityTuplizerFactory()
|
EventListeners |
getEventListeners()
|
Map |
getFilterDefinitions()
|
Map |
getImports()
Get the query language imports |
Interceptor |
getInterceptor()
Return the configured Interceptor |
Map |
getNamedQueries()
Get the named queries |
Map |
getNamedSQLQueries()
|
NamingStrategy |
getNamingStrategy()
|
Properties |
getProperties()
Get all properties |
String |
getProperty(String propertyName)
Get a property |
SessionFactoryObserver |
getSessionFactoryObserver()
|
Map |
getSqlFunctions()
|
Map |
getSqlResultSetMappings()
|
Iterator |
getTableMappings()
Iterate the table mappings |
Configuration |
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 void |
parseMappingElement(org.dom4j.Element subelement,
String name)
|
protected void |
reset()
|
protected void |
secondPassCompile()
|
protected void |
secondPassCompileForeignKeys(Table table,
Set done)
|
Configuration |
setCacheConcurrencyStrategy(String clazz,
String concurrencyStrategy)
Set up a cache for an entity class |
void |
setCacheConcurrencyStrategy(String clazz,
String concurrencyStrategy,
String region)
|
Configuration |
setCollectionCacheConcurrencyStrategy(String collectionRole,
String concurrencyStrategy)
Set up a cache for a collection role |
void |
setCollectionCacheConcurrencyStrategy(String collectionRole,
String concurrencyStrategy,
String region)
|
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)
Configure an Interceptor |
void |
setListener(String type,
Object listener)
|
void |
setListener(String type,
String listener)
|
void |
setListeners(String type,
Object[] listeners)
|
void |
setListeners(String type,
String[] listenerClasses)
|
Configuration |
setNamingStrategy(NamingStrategy namingStrategy)
Set a custom naming strategy |
Configuration |
setProperties(Properties properties)
Specify a completely new set of properties |
Configuration |
setProperty(String propertyName,
String value)
Set a property |
void |
setSessionFactoryObserver(SessionFactoryObserver sessionFactoryObserver)
|
void |
validateSchema(Dialect dialect,
DatabaseMetadata databaseMetadata)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map classes
protected Map imports
protected Map collections
protected Map tables
protected List auxiliaryDatabaseObjects
protected Map sqlFunctions
protected Map namedQueries
protected Map namedSqlQueries
protected Map sqlResultSetMappings
protected Map filterDefinitions
protected List secondPasses
protected List propertyReferences
protected Map extendsQueue
protected Map tableNameBinding
protected Map columnNameBindingPerTable
protected transient XMLHelper xmlHelper
protected transient Map typeDefs
protected NamingStrategy namingStrategy
protected final SettingsFactory settingsFactory
Constructor Detail |
---|
protected Configuration(SettingsFactory settingsFactory)
public Configuration()
Method Detail |
---|
protected void reset()
public EntityTuplizerFactory getEntityTuplizerFactory()
public Iterator getClassMappings()
public Iterator getCollectionMappings()
public Iterator getTableMappings()
public PersistentClass getClassMapping(String entityName)
entityName
- An entity name.
public Collection getCollectionMapping(String role)
role
- a collection role
public void setEntityResolver(EntityResolver entityResolver)
DTDEntityResolver
entityResolver
- entity resolver to usepublic EntityResolver getEntityResolver()
public EntityNotFoundDelegate getEntityNotFoundDelegate()
public void setEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate)
entityNotFoundDelegate
- The delegate to usepublic Configuration addFile(String xmlFile) throws MappingException
xmlFile
- a path to a file
MappingException
- Indicates inability to locate or parse
the specified mapping file.addFile(java.io.File)
public Configuration addFile(File xmlFile) throws MappingException
xmlFile
- a path to a file
MappingException
- Indicates inability to locate or parse
the specified mapping file.public Configuration addCacheableFile(File xmlFile) throws MappingException
xmlFile
- The cacheable mapping file to be added.
MappingException
- Indicates problems reading the cached file or processing
the non-cached file.public Configuration addCacheableFile(String xmlFile) throws MappingException
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.addCacheableFile(java.io.File)
public Configuration addXML(String xml) throws MappingException
xml
- an XML string
MappingException
- Indicates problems parsing the
given XML stringpublic Configuration addURL(URL url) throws MappingException
url
- The url for the mapping document to be read.
MappingException
- Indicates problems reading the URL or processing
the mapping document.public Configuration addDocument(Document doc) throws MappingException
doc
- The DOM document
MappingException
- Indicates problems reading the DOM or processing
the mapping document.public Configuration addInputStream(InputStream xmlInputStream) throws MappingException
InputStream
.
xmlInputStream
- The input stream containing a DOM.
MappingException
- Indicates problems reading the stream, or
processing the contained mapping document.public Configuration addResource(String resourceName, ClassLoader classLoader) throws MappingException
resourceName
- The resource nameclassLoader
- The class loader to use.
MappingException
- Indicates problems locating the resource or
processing the contained mapping document.public Configuration addResource(String resourceName) throws MappingException
resourceName
- The resource name
MappingException
- Indicates problems locating the resource or
processing the contained mapping document.public Configuration addClass(Class persistentClass) throws MappingException
persistentClass
- The mapped class
MappingException
- Indicates problems locating the resource or
processing the contained mapping document.public Configuration addJar(File jar) throws MappingException
jar
- a jar file
MappingException
- Indicates problems reading the jar file or
processing the contained mapping documents.public Configuration addDirectory(File dir) throws MappingException
dir
- The directory
MappingException
- Indicates problems reading the jar file or
processing the contained mapping documents.protected void add(org.dom4j.Document doc) throws MappingException
MappingException
public Mappings createMappings()
public String[] generateDropSchemaScript(Dialect dialect) throws HibernateException
HibernateException
SchemaExport
public String[] generateSchemaCreationScript(Dialect dialect) throws HibernateException
HibernateException
SchemaExport
public String[] generateSchemaUpdateScript(Dialect dialect, DatabaseMetadata databaseMetadata) throws HibernateException
HibernateException
SchemaUpdate
public void validateSchema(Dialect dialect, DatabaseMetadata databaseMetadata) throws HibernateException
HibernateException
public void buildMappings()
protected void secondPassCompile() throws MappingException
MappingException
protected org.dom4j.Document findPossibleExtends()
protected void secondPassCompileForeignKeys(Table table, Set done) throws MappingException
MappingException
public Map getNamedQueries()
public SessionFactory buildSessionFactory() throws HibernateException
HibernateException
SessionFactory
public Interceptor getInterceptor()
public Properties getProperties()
public Configuration setInterceptor(Interceptor interceptor)
public Configuration setProperties(Properties properties)
public Configuration addProperties(Properties extraProperties)
public Configuration mergeProperties(Properties properties)
properties
-
public Configuration setProperty(String propertyName, String value)
public String getProperty(String propertyName)
protected InputStream getConfigurationInputStream(String resource) throws HibernateException
HibernateException
public Configuration configure() throws HibernateException
HibernateException
public Configuration configure(String resource) throws HibernateException
HibernateException
public Configuration configure(URL url) throws HibernateException
url
- URL from which you wish to load the configuration
HibernateException
public Configuration configure(File configFile) throws HibernateException
configFile
- File from which you wish to load the configuration
HibernateException
protected Configuration doConfigure(InputStream stream, String resourceName) throws HibernateException
stream
- Inputstream to be read fromresourceName
- The name to use in warning/error messages
HibernateException
public Configuration configure(Document document) throws HibernateException
document
- an XML document from which you wish to load the configuration
HibernateException
- if there is problem in accessing the file.protected Configuration doConfigure(org.dom4j.Document doc) throws HibernateException
HibernateException
protected void parseMappingElement(org.dom4j.Element subelement, String name)
public void setListener(String type, String listener)
public void setListeners(String type, String[] listenerClasses)
public void setListener(String type, Object listener)
public void setListeners(String type, Object[] listeners)
public EventListeners getEventListeners()
public Configuration setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy) throws MappingException
clazz
- concurrencyStrategy
-
MappingException
public void setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy, String region) throws MappingException
MappingException
public Configuration setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy) throws MappingException
collectionRole
- concurrencyStrategy
-
MappingException
public void setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy, String region) throws MappingException
MappingException
public Map getImports()
public Settings buildSettings() throws HibernateException
HibernateException
public Settings buildSettings(Properties props) throws HibernateException
HibernateException
public Map getNamedSQLQueries()
public Map getSqlResultSetMappings()
public NamingStrategy getNamingStrategy()
public Configuration setNamingStrategy(NamingStrategy namingStrategy)
namingStrategy
- the NamingStrategy to setpublic Mapping buildMapping()
public Map getFilterDefinitions()
public void addFilterDefinition(FilterDefinition definition)
public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject object)
public Map getSqlFunctions()
public void addSqlFunction(String functionName, SQLFunction function)
public SessionFactoryObserver getSessionFactoryObserver()
public void setSessionFactoryObserver(SessionFactoryObserver sessionFactoryObserver)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |