Showing posts with label JTA. Show all posts
Showing posts with label JTA. Show all posts

Wednesday, April 6, 2011

Use of persistence.xml file

The EntityManager API is great, but how does the server/ application know which database it is supposed to save / update / query the entity objects?
How do we configure the underlying object-relational-mapping engine and cache for better performance and trouble shooting? The persistence.xml file gives you complete flexibility to configure the EntityManager.
  • The persistence.xml file is a standard configuration file in JPA.
  • It has to be included in the META-INF directory inside the JAR file that contains the entity beans.
  • The persistence.xml file must define a persistence-unit with a unique name in the current scoped classloader.
  • The provider attribute specifies the underlying implementation of the JPA EntityManager. 
  • In JBoss AS, the default and only supported / recommended JPA provider is Hibernate.
  • The jta-data-source points to the JNDI name of the database this persistence unit maps to e.g. java:/DefaultDS.