Version 3

    Datasource and Hibernate Configuration

    JBoss EJB 3.0 is built on top of Hibernate 3.0.  To configure the datasource your entity beans will use requires creating a persistence.properties file.  There is a default persistence.properties file for every EJB 3.0 deployment in the package ejb3.deployer/META-INF/persistence.properties.

     

    Please refer to the Hibernate 3.0 documentation in this distribution for how to configure the values in the persistence.properties file.  Here's a little explanation though:

     

    hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup
    hibernate.hbm2ddl.auto=create-drop
    hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
    hibernate.connection.datasource=java:/DefaultDS
    hibernate.dialect=org.hibernate.dialect.HSQLDialect
    

     

    The above is the default persistence.properties that will be used for your EJB 3.0 applications ejb3.deployer/META-INF/persistence.properties

     

    hibernate.connection.datasource points to the JNDI name of the JBoss datasource.

     

    hibernate.dialect By default is Hypersonic SQL, but you can change it to other dialects like Oracle.  Consult the Hibernate 3.0 documentation.

     

    hibernate.hbm2ddl.auto=create-drop Creates the database schema on deploy, deletes it on undeploy.

     

    hibernate.transaction.manager_lookup_class defines Hibernates transaction management.  It should not change from the above value.

     

    hibernate.cache.provider_class Defines the caching architecture that Hibernate should use.  You may want to consider JBoss Cache if you're using this in a cluster.

     

    Hibernate.properties Per Deployment

    You will probably need to override the default hibernate.properties file.  To do this, create your own hibernate.properties file with all the above variables defined in minimum.  Place this hibernate.properties file the META-INF/ directory of your .ejb3 jar or within your EAR file.