234 APPENDIX A n MORE ADVANCED FEATURES APPENDIX A n MORE ADVANCED FEATURES
com.hibernatebook.advanced.Sample
The configuration file can contain multiple named
elements, each corresponding to a different configuration of the ORM environment. In the example in Listing A-1, we have created a single annotation-mapped entity. The
element then configures the implementation-specific (i.e., Hibernate-specific) properties. In Listing A-1, we have configured a database connection and dialect. When configuring a J2EE environment, the connection would usually be provided through generic elements of the persistence unit; Listing A-2 shows a configuration that takes advantage of this approach. Listing A-2. An EJB 3 persistence.xml Configuration File Using a JTA Data Source
java:comp/env/jdbc/advanced com.hibernatebook.advanced.Sample
Listing A-2 shows that the configuration file requires very little Hibernate-specific information. In a J2EE environment, it is possible at deployment time to substitute alternative EJB 3 providers for the providers indicated in the application s metadata. In a J2SE environment, the configuration information is accessed by creating an EntityManagerFactory class by calling the createEntityManagerFactory()method of the Persistence class, with the configured name of the persistence unit (shown in bold in
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.
This entry was posted
on Friday, August 3rd, 2007 at 12:15 pm and is filed under tomcat.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.