aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Why two xml files? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Why two xml files?" Watch "Why two xml files?" New topic
Author

Why two xml files?

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9521
    
    2

Guys,

What is the need for orm.xml and persistence.xml files?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Leandro Siqueira
Greenhorn

Joined: Jun 05, 2005
Posts: 6
  • persistence.xml defines the identities and configuration properties of persistence units;
  • orm.xml is optional and defines the mapping between classes and persistence units.



  • [ October 22, 2008: Message edited by: Leandro Siqueira ]
    [ October 22, 2008: Message edited by: Leandro Siqueira ]
    Joe Harry
    Ranch Hand

    Joined: Sep 26, 2006
    Posts: 9521
        
        2

    If I do not provide an orm.xml file, then the persistence provider will automatically map my POJO's based on the metadata annotations that I have. Am I right in this sense?
    Leandro Siqueira
    Greenhorn

    Joined: Jun 05, 2005
    Posts: 6
    exactly!

    and if you have both, xml overrides the annotations.
    Joe Harry
    Ranch Hand

    Joined: Sep 26, 2006
    Posts: 9521
        
        2

    If I were to relate this with Hibernate, a persistence.xml is something like a hibernate-cfg.xml and the orm.xml is like a mapping xml that we have in Hibernate.
    Chaminda Amarasinghe
    Ranch Hand

    Joined: May 17, 2006
    Posts: 402
    Yes you are correct
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: Why two xml files?