fix failing test

Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa22/advanced/XMLForeignKeyTestSuite.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa22/advanced/XMLForeignKeyTestSuite.java
index 4fe5857..a9dd7bd 100644
--- a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa22/advanced/XMLForeignKeyTestSuite.java
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa22/advanced/XMLForeignKeyTestSuite.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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.
@@ -182,6 +182,9 @@ public void testElementCollectionForeignKeys() {
     public void testReadAndWriteDDLObjects() {
         // Load scripts for this PU are built for MySql
         if (getPlatform().isMySQL()) {
+            if (doesEntityManagerFactoryExist()) {
+                closeEntityManagerFactory();
+            }
             EntityManager em = createEntityManager();
 
             try {