Attila Csipak
Attila Csipak

Reputation: 1062

Is the order of <class> elements in persistence.xml important in any way?

Consider the following example:

<?xml version="1.0" encoding="UTF-8"?>
<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-unit name="production">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <mapping-file>META-INF/orm.xml</mapping-file>
        <class>com.foo.EntityClassA</class>
        <class>com.foo.EntityClassC</class>
        <class>com.foo.EntityClassB</class>
        <!-- ... -->
    </persistence-unit>
</persistence>

Is the ordering of the class tags important in any way?

In other words: is there a risk of changing / breaking funcionality if I change the order of managed class declarations in a persistence.xml?

If the answer starts as "It depends...", then the question is: where should I start to research an exact case?

Upvotes: 0

Views: 245

Answers (1)

The order of classes defined in the persistence.xml file doesn't matter.

Upvotes: 4

Related Questions