In EJB 3.0, persistence is done using plain old java objects (POJOs). As far as I know, JBoss is the only J2EE capable application server supporting EJB 3.0 at this point. In the JBoss implementation the Hibernate roots of persistent POJOs are still very much visable. That's good news since that means that much of the Hibernate documentation can be used to understand EJB 3.0.
In JBoss, the default persitence properties are stored in
$JBOSS_HOME/server/all/deploy/ejb3.deployer/META-INF/persistence.properties
The meaning of most of the configuration parameters you see there can be found in the Hibernate configuration documentation.
By default, the persistence configuration on JBoss's EJB3.0 says to create new tables each time the application is deployed and to drop tables when it's undeployed:
hibernate.hbm2ddl.auto=create-drop
This means that your data will be lost each time you redeploy your application. Probably OK when you're developing your entities, but not what you want for a production database. To change this, you can either change the line to read
hibernate.hbm2ddl.auto=update
Theoretically, you can override the default in your persistence.xml deployment descriptor:
<entity-manager> <name>Animal</name> <jta-data-source>java:/DefaultDS</jta-data-source> <properties> <property name="hibernate.hbm2dll.auto" Value="update"/> </properties> </entity-manager>
I found, however, in a few simple tests, that this didn't work.
The default data source in JBoss is the Hypersonic database. This is an easy way to get going. JBoss stores the data in
$JBOSS_HOME/server/all/data/hypersonic
with the name localDB. This name, along with other configuration parameters for the Hypersonic DB, which is given the JNDI name DefaultDS can be found in this file:
$JBOSS_HOME/server/all/deploy/hsqldb-ds.xml