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
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:
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
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
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: