org.hibernate.ejb
Class Ejb3Configuration

java.lang.Object
  extended by org.hibernate.ejb.Ejb3Configuration
All Implemented Interfaces:
Serializable, Referenceable

public class Ejb3Configuration
extends Object
implements Serializable, Referenceable

Allow a fine tuned configuration of an EJB 3.0 EntityManagerFactory A Ejb3Configuration object is only guaranteed to create one EntityManagerFactory. Multiple usage of #buildEntityManagerFactory() is not guaranteed. After #buildEntityManagerFactory() has been called, you no longer can change the configuration state (no class adding, no property change etc) When serialized / deserialized or retrieved from the JNDI, you no longer can change the configuration state (no class adding, no property change etc) Putting the configuration in the JNDI is an expensive operation that requires a partial serialization

Author:
Emmanuel Bernard
See Also:
Serialized Form

Constructor Summary
Ejb3Configuration()
           
 
Method Summary
 Ejb3Configuration addAnnotatedClass(Class persistentClass)
           
 void addAuxiliaryDatabaseObject(org.hibernate.mapping.AuxiliaryDatabaseObject object)
           
 Ejb3Configuration addClass(Class persistentClass)
           
 Ejb3Configuration addFile(File xmlFile)
           
 Ejb3Configuration addFile(String xmlFile)
           
 void addFilterDefinition(org.hibernate.engine.FilterDefinition definition)
           
 Ejb3Configuration addInputStream(InputStream xmlInputStream)
           
 Ejb3Configuration addPackage(String packageName)
           
 Ejb3Configuration addProperties(Properties props)
           
 Ejb3Configuration addResource(String path)
           
 Ejb3Configuration addResource(String path, ClassLoader classLoader)
           
 javax.persistence.EntityManagerFactory buildEntityManagerFactory()
           
 void buildMappings()
           
 org.hibernate.cfg.Settings buildSettings()
           
 Ejb3Configuration configure(javax.persistence.spi.PersistenceUnitInfo info, Map integration)
          Process configuration from a PersistenceUnitInfo object Typically called by the container
 Ejb3Configuration configure(String resource)
           
 Ejb3Configuration configure(String persistenceUnitName, Map integration)
          Build the configuration from an entity manager name and given the appropriate extra properties.
 javax.persistence.EntityManagerFactory createEntityManagerFactory()
          Deprecated.  
 javax.persistence.EntityManagerFactory createEntityManagerFactory(Map workingVars)
          Deprecated. use the Java Persistence API
 org.hibernate.mapping.PersistentClass getClassMapping(String persistentClass)
           
 Iterator getClassMappings()
           
 org.hibernate.mapping.Collection getCollectionMapping(String role)
           
 org.hibernate.event.EventListeners getEventListeners()
           
 Map getFilterDefinitions()
           
 org.hibernate.cfg.AnnotationConfiguration getHibernateConfiguration()
          This API is intended to give a read-only configuration.
 org.hibernate.Interceptor getInterceptor()
           
 Map getNamedQueries()
           
 org.hibernate.cfg.NamingStrategy getNamingStrategy()
           
 Properties getProperties()
           
 Reference getReference()
           
 Iterator getTableMappings()
           
 void setDataSource(DataSource ds)
          Used to inject a datasource object as the connection provider.
 void setEntityResolver(EntityResolver entityResolver)
           
 Ejb3Configuration setInterceptor(org.hibernate.Interceptor interceptor)
           
 void setListeners(String type, Object[] listeners)
           
 void setListeners(String type, String[] listenerClasses)
           
 Ejb3Configuration setNamingStrategy(org.hibernate.cfg.NamingStrategy namingStrategy)
           
 Ejb3Configuration setProperties(Properties properties)
           
 Ejb3Configuration setProperty(String key, String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ejb3Configuration

public Ejb3Configuration()
Method Detail

setDataSource

public void setDataSource(DataSource ds)
Used to inject a datasource object as the connection provider. If used, be sure to not override the hibernate.connection.provider_class property


configure

public Ejb3Configuration configure(String persistenceUnitName,
                                   Map integration)
Build the configuration from an entity manager name and given the appropriate extra properties. Those properties override the one get through the peristence.xml file. If the persistence unit name is not found or does not match the Persistence Provider, null is returned This method is used in a non managed environment

Parameters:
persistenceUnitName - persistence unit name
integration - properties passed to the persistence provider
Returns:
configured Ejb3Configuration or null if no persistence unit match

configure

public Ejb3Configuration configure(javax.persistence.spi.PersistenceUnitInfo info,
                                   Map integration)
Process configuration from a PersistenceUnitInfo object Typically called by the container


setProperty

public Ejb3Configuration setProperty(String key,
                                     String value)

createEntityManagerFactory

public javax.persistence.EntityManagerFactory createEntityManagerFactory(Map workingVars)
Deprecated. use the Java Persistence API

create a factory from a list of properties and HibernatePersistence.CLASS_NAMES -> Collection (use to list the classes from config files HibernatePersistence.PACKAGE_NAMES -> Collection (use to list the mappings from config files HibernatePersistence.HBXML_FILES -> Collection (input streams of hbm files) HibernatePersistence.LOADED_CLASSES -> Collection (list of loaded classes)

Used by JBoss AS only


createEntityManagerFactory

public javax.persistence.EntityManagerFactory createEntityManagerFactory()
Deprecated. 

Process configuration and build an EntityManagerFactory when the configuration is ready


buildEntityManagerFactory

public javax.persistence.EntityManagerFactory buildEntityManagerFactory()

getReference

public Reference getReference()
                       throws NamingException
Specified by:
getReference in interface Referenceable
Throws:
NamingException

buildSettings

public org.hibernate.cfg.Settings buildSettings()
                                         throws org.hibernate.HibernateException
Throws:
org.hibernate.HibernateException

addProperties

public Ejb3Configuration addProperties(Properties props)

addAnnotatedClass

public Ejb3Configuration addAnnotatedClass(Class persistentClass)
                                    throws org.hibernate.MappingException
Throws:
org.hibernate.MappingException

configure

public Ejb3Configuration configure(String resource)
                            throws org.hibernate.HibernateException
Throws:
org.hibernate.HibernateException

addPackage

public Ejb3Configuration addPackage(String packageName)
                             throws org.hibernate.MappingException
Throws:
org.hibernate.MappingException

addFile

public Ejb3Configuration addFile(String xmlFile)
                          throws org.hibernate.MappingException
Throws:
org.hibernate.MappingException

addClass

public Ejb3Configuration addClass(Class persistentClass)
                           throws org.hibernate.MappingException
Throws:
org.hibernate.MappingException

addFile

public Ejb3Configuration addFile(File xmlFile)
                          throws org.hibernate.MappingException
Throws:
org.hibernate.MappingException

buildMappings

public void buildMappings()

getClassMappings

public Iterator getClassMappings()

getEventListeners

public org.hibernate.event.EventListeners getEventListeners()

getTableMappings

public Iterator getTableMappings()

getClassMapping

public org.hibernate.mapping.PersistentClass getClassMapping(String persistentClass)

getCollectionMapping

public org.hibernate.mapping.Collection getCollectionMapping(String role)

setEntityResolver

public void setEntityResolver(EntityResolver entityResolver)

getNamedQueries

public Map getNamedQueries()

getInterceptor

public org.hibernate.Interceptor getInterceptor()

getProperties

public Properties getProperties()

setInterceptor

public Ejb3Configuration setInterceptor(org.hibernate.Interceptor interceptor)

setProperties

public Ejb3Configuration setProperties(Properties properties)

getFilterDefinitions

public Map getFilterDefinitions()

addFilterDefinition

public void addFilterDefinition(org.hibernate.engine.FilterDefinition definition)

addAuxiliaryDatabaseObject

public void addAuxiliaryDatabaseObject(org.hibernate.mapping.AuxiliaryDatabaseObject object)

getNamingStrategy

public org.hibernate.cfg.NamingStrategy getNamingStrategy()

setNamingStrategy

public Ejb3Configuration setNamingStrategy(org.hibernate.cfg.NamingStrategy namingStrategy)

setListeners

public void setListeners(String type,
                         String[] listenerClasses)

setListeners

public void setListeners(String type,
                         Object[] listeners)

getHibernateConfiguration

public org.hibernate.cfg.AnnotationConfiguration getHibernateConfiguration()
This API is intended to give a read-only configuration. It is sueful when working with SchemaExport or any Configuration based tool. DO NOT update configuration through it.


addInputStream

public Ejb3Configuration addInputStream(InputStream xmlInputStream)
                                 throws org.hibernate.MappingException
Throws:
org.hibernate.MappingException

addResource

public Ejb3Configuration addResource(String path)
                              throws org.hibernate.MappingException
Throws:
org.hibernate.MappingException

addResource

public Ejb3Configuration addResource(String path,
                                     ClassLoader classLoader)
                              throws org.hibernate.MappingException
Throws:
org.hibernate.MappingException