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.

2 comments:

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

    Javin
    <a href="http://javarevisited.blogspot.com/2011/04/top-20-core-java-interview-questions.html>Top 20 Core Java Interview question</a>

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

      http://thecafetechno.com/tutorials/interview-questions/most-frequently-asked-core-java-interview-questions-and-answers/

      Delete