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.


  1. Thanks for your comment in my blog Sharad. you have good content and very good blog man. keep it up.

    <a href=">Top 20 Core Java Interview question</a>

    1. thanks for sharing this article sharad... please allow me to share a nice article of mine: