It is a simple exercise to package and deploy persistence applications using the Java Persistence API. In most cases it is just a matter of adding a very short persistence.xml file to the JAR containing the entity classes.
In this chapter we described how to configure the persistence unit in the Java EE server environment using the persistence.xml file and how in some cases the name may be the only setting required. We then explained when to apply and how to specify the transaction type, the persistence provider, and the data source. We showed how to use and specify the default orm.xml mapping file and then went on to use additional mapping files within the same persistence unit. We also discussed the various ways that classes may be included in the persistence unit and how to customize the persistence unit using vendor-specific properties.
We looked at the ways that persistence units may be packaged and deployed to a Java EE application as part of an EJB archive, a web archive, or a persistence archive that is accessible to all of the components in the application. We examined how persistence units may exist within different scopes of a deployed Java EE application and what the name-scoping rules were.
Finally we compared the configuration and deployment practices to deploying an application to a Java SE environment.
In the next chapter we will consider the accepted and best practices for testing applications that use persistence.
Unable to display preview. Download preview PDF.