Bug 521954: Eclipselink 2.7 is not able to parse ORM XML files using the 2.2 schema - modelgen

Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
Reviewed-by: Joe
diff --git a/jpa/org.eclipse.persistence.jpa.modelgen/src/org/eclipse/persistence/internal/jpa/modelgen/objects/PersistenceUnit.java b/jpa/org.eclipse.persistence.jpa.modelgen/src/org/eclipse/persistence/internal/jpa/modelgen/objects/PersistenceUnit.java
index e3708ae..72dc65f 100644
--- a/jpa/org.eclipse.persistence.jpa.modelgen/src/org/eclipse/persistence/internal/jpa/modelgen/objects/PersistenceUnit.java
+++ b/jpa/org.eclipse.persistence.jpa.modelgen/src/org/eclipse/persistence/internal/jpa/modelgen/objects/PersistenceUnit.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 1998, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017 Oracle and/or its affiliates. All rights reserved.
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
  * which accompanies this distribution.
@@ -22,6 +22,8 @@
  *       - 338610: JPA 2.1 Functionality for Java EE 7 (JSR-338)
  *     05/26/2016-2.7 Tomas Kraus
  *       - 494610: Session Properties map should be Map<String, Object>
+ *     10/09/2017-2.7 Lukas Jungmann
+ *       - 521954: Eclipselink 2.7 is not able to parse ORM XML files using the 2.2 schema
  ******************************************************************************/
 package org.eclipse.persistence.internal.jpa.modelgen.objects;
 
@@ -277,15 +279,20 @@ protected void addXMLEntityMappings(String mappingFile) {
             addXMLEntityMappings(mappingFile, XMLEntityMappingsReader.getEclipseLinkOrmProject());
         } catch (XMLMarshalException e) {
             try {
-                // Try JPA 2.1 project
-                addXMLEntityMappings(mappingFile, XMLEntityMappingsReader.getOrm2_1Project());
-            } catch (XMLMarshalException ee) {
+                // Try JPA 2.2 project
+                addXMLEntityMappings(mappingFile, XMLEntityMappingsReader.getOrm2_2Project());
+            } catch (XMLMarshalException xme) {
                 try {
-                    // Try JPA 2.0 project
-                    addXMLEntityMappings(mappingFile, XMLEntityMappingsReader.getOrm2_0Project());
-                } catch (XMLMarshalException eee) {
-                    // Try JPA 1.0 project (don't catch exceptions at this point)
-                    addXMLEntityMappings(mappingFile, XMLEntityMappingsReader.getOrm1_0Project());
+                    // Try JPA 2.1 project
+                    addXMLEntityMappings(mappingFile, XMLEntityMappingsReader.getOrm2_1Project());
+                } catch (XMLMarshalException ee) {
+                    try {
+                        // Try JPA 2.0 project
+                        addXMLEntityMappings(mappingFile, XMLEntityMappingsReader.getOrm2_0Project());
+                    } catch (XMLMarshalException eee) {
+                        // Try JPA 1.0 project (don't catch exceptions at this point)
+                        addXMLEntityMappings(mappingFile, XMLEntityMappingsReader.getOrm1_0Project());
+                    }
                 }
             }
         }