Save This Page
Home » Hibernate-3.3.2.GA » org.hibernate » cfg » [javadoc | source]
org.hibernate.cfg
public class: Configuration [javadoc | source]
java.lang.Object
   org.hibernate.cfg.Configuration

All Implemented Interfaces:
    Serializable

Direct Known Subclasses:
    JDBCMetaDataConfiguration, AnnotationConfiguration

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.
Field Summary
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    Map result set name, result set description 
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:
 public Configuration() 
 protected Configuration(SettingsFactory settingsFactory) 
Method from org.hibernate.cfg.Configuration Summary:
add,   addAuxiliaryDatabaseObject,   addCacheableFile,   addCacheableFile,   addClass,   addDirectory,   addDocument,   addFile,   addFile,   addFilterDefinition,   addInputStream,   addJar,   addProperties,   addResource,   addResource,   addSqlFunction,   addURL,   addXML,   buildMapping,   buildMappings,   buildSessionFactory,   buildSettings,   buildSettings,   configure,   configure,   configure,   configure,   configure,   createMappings,   doConfigure,   doConfigure,   findPossibleExtends,   generateDropSchemaScript,   generateSchemaCreationScript,   generateSchemaUpdateScript,   getClassMapping,   getClassMappings,   getCollectionMapping,   getCollectionMappings,   getConfigurationInputStream,   getEntityNotFoundDelegate,   getEntityResolver,   getEntityTuplizerFactory,   getEventListeners,   getFilterDefinitions,   getImports,   getInterceptor,   getNamedQueries,   getNamedSQLQueries,   getNamingStrategy,   getProperties,   getProperty,   getRootClassMapping,   getSessionFactoryObserver,   getSqlFunctions,   getSqlResultSetMappings,   getTableMappings,   mergeProperties,   parseMappingElement,   reset,   secondPassCompile,   secondPassCompileForeignKeys,   setCacheConcurrencyStrategy,   setCacheConcurrencyStrategy,   setCacheConcurrencyStrategy,   setCollectionCacheConcurrencyStrategy,   setCollectionCacheConcurrencyStrategy,   setEntityNotFoundDelegate,   setEntityResolver,   setInterceptor,   setListener,   setListener,   setListeners,   setListeners,   setNamingStrategy,   setProperties,   setProperty,   setSessionFactoryObserver,   validateSchema
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.hibernate.cfg.Configuration Detail:
 protected  void add(Document doc) throws MappingException 
 public  void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject object) 
 public Configuration addCacheableFile(File xmlFile) throws MappingException 
    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.
 public Configuration addCacheableFile(String xmlFile) throws MappingException 
    Add a cacheable mapping file.
 public Configuration addClass(Class persistentClass) throws MappingException 
    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.
 public Configuration addDirectory(File dir) throws MappingException 
    Read all mapping documents from a directory tree.

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

 public Configuration addDocument(Document doc) throws MappingException 
    Read mappings from a DOM Document
 public Configuration addFile(String xmlFile) throws MappingException 
    Read mappings from a particular XML file
 public Configuration addFile(File xmlFile) throws MappingException 
    Read mappings from a particular XML file
 public  void addFilterDefinition(FilterDefinition definition) 
 public Configuration addInputStream(InputStream xmlInputStream) throws MappingException 
 public Configuration addJar(File jar) throws MappingException 
    Read all mappings from a jar file

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

 public Configuration addProperties(Properties extraProperties) 
    Set the given properties
 public Configuration addResource(String resourceName) throws MappingException 
    Read mappings as a application resourceName (i.e. classpath lookup) trying different classloaders.
 public Configuration addResource(String resourceName,
    ClassLoader classLoader) throws MappingException 
    Read mappings as a application resource (i.e. classpath lookup).
 public  void addSqlFunction(String functionName,
    SQLFunction function) 
 public Configuration addURL(URL url) throws MappingException 
    Read mappings from a URL
 public Configuration addXML(String xml) throws MappingException 
    Read mappings from a String
 public Mapping buildMapping() 
 public  void buildMappings() 
    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().
 public SessionFactory buildSessionFactory() throws HibernateException 
    Instantiate a new SessionFactory, using the properties and mappings in this configuration. The SessionFactory will be immutable, so changes made to the Configuration after building the SessionFactory will not affect it.
 public Settings buildSettings() throws HibernateException 
    Create an object-oriented view of the configuration properties
 public Settings buildSettings(Properties props) throws HibernateException 
 public Configuration configure() throws HibernateException 
    Use the mappings and properties specified in an application resource named hibernate.cfg.xml.
 public Configuration configure(String resource) throws HibernateException 
    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(resource).

 public Configuration configure(URL url) throws HibernateException 
    Use the mappings and properties specified in the given document. The format of the document is defined in hibernate-configuration-3.0.dtd.
 public Configuration configure(File configFile) throws HibernateException 
    Use the mappings and properties specified in the given application file. The format of the file is defined in hibernate-configuration-3.0.dtd.
 public Configuration configure(Document document) throws HibernateException 
    Use the mappings and properties specified in the given XML document. The format of the file is defined in hibernate-configuration-3.0.dtd.
 public Mappings createMappings() 
    Create a new Mappings to add class and collection mappings to.
 protected Configuration doConfigure(Document doc) throws HibernateException 
 protected Configuration doConfigure(InputStream stream,
    String resourceName) throws HibernateException 
    Use the mappings and properties specified in the given application resource. The format of the resource is defined in hibernate-configuration-3.0.dtd.
 protected Document findPossibleExtends() 
    Find the first possible element in the queue of extends.
 public String[] generateDropSchemaScript(Dialect dialect) throws HibernateException 
    Generate DDL for dropping tables
 public String[] generateSchemaCreationScript(Dialect dialect) throws HibernateException 
    Generate DDL for creating tables
 public String[] generateSchemaUpdateScript(Dialect dialect,
    DatabaseMetadata databaseMetadata) throws HibernateException 
    Generate DDL for altering tables
 public PersistentClass getClassMapping(String entityName) 
    Get the mapping for a particular entity
 public Iterator getClassMappings() 
    Iterate the entity mappings
 public Collection getCollectionMapping(String role) 
    Get the mapping for a particular collection role
 public Iterator getCollectionMappings() 
    Iterate the collection mappings
 protected InputStream getConfigurationInputStream(String resource) throws HibernateException 
    Get the configuration file as an InputStream. Might be overridden by subclasses to allow the configuration to be located by some arbitrary mechanism.
 public EntityNotFoundDelegate getEntityNotFoundDelegate() 
    Retrieve the user-supplied delegate to handle non-existent entity scenarios. May be null.
 public EntityResolver getEntityResolver() 
 public EntityTuplizerFactory getEntityTuplizerFactory() 
 public EventListeners getEventListeners() 
 public Map getFilterDefinitions() 
 public Map getImports() 
    Get the query language imports
 public Interceptor getInterceptor() 
    Return the configured Interceptor
 public Map getNamedQueries() 
    Get the named queries
 public Map getNamedSQLQueries() 
 public NamingStrategy getNamingStrategy() 
 public Properties getProperties() 
    Get all properties
 public String getProperty(String propertyName) 
    Get a property
 RootClass getRootClassMapping(String clazz) throws MappingException 
 public SessionFactoryObserver getSessionFactoryObserver() 
 public Map getSqlFunctions() 
 public Map getSqlResultSetMappings() 
 public Iterator getTableMappings() 
    Iterate the table mappings
 public 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(Element subelement,
    String name) 
 protected  void reset() 
 protected  void secondPassCompile() throws MappingException 
 protected  void secondPassCompileForeignKeys(Table table,
    Set done) throws MappingException 
 public Configuration setCacheConcurrencyStrategy(String clazz,
    String concurrencyStrategy) throws MappingException 
    Set up a cache for an entity class
 public  void setCacheConcurrencyStrategy(String clazz,
    String concurrencyStrategy,
    String region) throws MappingException 
  void setCacheConcurrencyStrategy(String clazz,
    String concurrencyStrategy,
    String region,
    boolean includeLazy) throws MappingException 
 public Configuration setCollectionCacheConcurrencyStrategy(String collectionRole,
    String concurrencyStrategy) throws MappingException 
    Set up a cache for a collection role
 public  void setCollectionCacheConcurrencyStrategy(String collectionRole,
    String concurrencyStrategy,
    String region) throws MappingException 
 public  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. This is mainly intended for EJB3 implementations to be able to control how proxy initialization errors should be handled...
 public  void setEntityResolver(EntityResolver entityResolver) 
 public Configuration setInterceptor(Interceptor interceptor) 
    Configure an 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 setNamingStrategy(NamingStrategy namingStrategy) 
    Set a custom naming strategy
 public Configuration setProperties(Properties properties) 
    Specify a completely new set of properties
 public Configuration setProperty(String propertyName,
    String value) 
    Set a property
 public  void setSessionFactoryObserver(SessionFactoryObserver sessionFactoryObserver) 
 public  void validateSchema(Dialect dialect,
    DatabaseMetadata databaseMetadata) throws HibernateException