orm.xml and persistence.xml templates

14 Jul
2012

As I keep finding myself searching for orm.xml templates as well as persistence.xml templates for JPA 1.0 and JPA 2.0, I decided to post them here for my own reference and others to find 😉

JPA 1.0 orm.xml and persistence.xml templates

orm.xml template for JPA 1.0

<?xml version="1.0" ?>
<entity-mappings
        xmlns="http://java.sun.com/xml/ns/persistence/orm"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
        http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
                 version="1.0">

</entity-mappings>

persistence.xml template for JPA 1.0

<?xml version="1.0" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">

</persistence>

JPA 2.0 orm.xml and persistence.xml templates

orm.xml template for JPA 2.0

<?xml version="1.0" ?>
<entity-mappings
        xmlns="http://java.sun.com/xml/ns/persistence/orm"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
        http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
                 version="2.0">

</entity-mappings>

persistence.xml template for jpa 2.0

<?xml version="1.0" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">

</persistence>

With these templates your favorite IDE should be able to autocomplete the allowed tags on its own.

Comment Form

top