aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Grassel2014-08-18 14:43:48 (EDT)
committerRick Curtis2014-08-19 22:38:47 (EDT)
commita7193b0d4f72190a6b3adf07108742669fb9326f (patch)
treebacddf071b41f566fe4900fc6f54eb7a477a5591
parent3211a448b374a8f2cf873268eca68e833dc05c4e (diff)
downloadeclipselink.runtime-a7193b0d4f72190a6b3adf07108742669fb9326f.zip
eclipselink.runtime-a7193b0d4f72190a6b3adf07108742669fb9326f.tar.gz
eclipselink.runtime-a7193b0d4f72190a6b3adf07108742669fb9326f.tar.bz2
Bug 440802 - Metadata Processing must ignore types not declared in XML when xml-mapping-metadata-complete is flagged
Signed-off-by: Joe Grassel <fyrewyld@gmail.com>
-rw-r--r--jpa/eclipselink.jpa.test/antbuild.properties2
-rw-r--r--jpa/eclipselink.jpa.test/antbuild.xml38
-rw-r--r--jpa/eclipselink.jpa.test/resource/eclipselink-xml-mapping-metadata-complete/ecl-xml-mapping-metadata-complete-mappings.xml16
-rw-r--r--jpa/eclipselink.jpa.test/resource/eclipselink-xml-mapping-metadata-complete/persistence.xml10
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/AnnotationOnlyEntity.java59
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/XLMMappingMetadataCompleteTableManager.java85
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/XMLOnlyEntity.java53
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/FullRegressionTestSuite.java6
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/xml/xmlmetadatacomplete/XMLMappingMetadataCompleteJunitTestCase.java113
-rw-r--r--jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProcessor.java10
10 files changed, 390 insertions, 2 deletions
diff --git a/jpa/eclipselink.jpa.test/antbuild.properties b/jpa/eclipselink.jpa.test/antbuild.properties
index e529950..4e1ce5c 100644
--- a/jpa/eclipselink.jpa.test/antbuild.properties
+++ b/jpa/eclipselink.jpa.test/antbuild.properties
@@ -121,6 +121,8 @@ eclipselink.xml.extended.composite.advanced.model.member_1=eclipselink-xml-exten
eclipselink.xml.extended.composite.advanced.model.member_2=eclipselink-xml-extended-composite-advanced-model-member_2
eclipselink.xml.extended.composite.advanced.model.member_3=eclipselink-xml-extended-composite-advanced-model-member_3
+eclipselink.xml.mapping.metadata.complete=eclipselink-xml-mapping-metadata-complete
+
eclipselink.struct.converter.model=eclipselink-struct-converter-model
eclipselink.timestamptz.model=eclipselink-timestamptz-model
eclipselink.customfeatures.model=eclipselink-customfeatures-model
diff --git a/jpa/eclipselink.jpa.test/antbuild.xml b/jpa/eclipselink.jpa.test/antbuild.xml
index 022a40d..7965c09 100644
--- a/jpa/eclipselink.jpa.test/antbuild.xml
+++ b/jpa/eclipselink.jpa.test/antbuild.xml
@@ -547,6 +547,7 @@
<fileset file="${jpatest.basedir}/${eclipselink.xml.extended.composite.advanced.model.member_2}.jar"/>
<fileset file="${jpatest.basedir}/${eclipselink.xml.extended.composite.advanced.model.member_3}.jar"/>
<fileset file="${jpatest.basedir}/eclipselink-remote.jar"/>
+ <fileset file="${jpatest.basedir}/${eclipselink.xml.mapping.metadata.complete}.jar"/>
</delete>
</target>
@@ -588,6 +589,7 @@
<mkdir dir="${jpatest.basedir}/${build.dir}/${eclipselink.xml.extended.composite.advanced.model.member_2}"/>
<mkdir dir="${jpatest.basedir}/${build.dir}/${eclipselink.xml.extended.composite.advanced.model.member_3}"/>
<mkdir dir="${jpatest.basedir}/${build.dir}/eclipselink-remote"/>
+ <mkdir dir="${jpatest.basedir}/${build.dir}/${eclipselink.xml.mapping.metadata.complete}"/>
</target>
<target name="model-compile" description="compile models that need canonical processing">
@@ -766,7 +768,7 @@
<target name="package" depends="config-classpath, package-annotation, package-ddl, package-xml-only, package-xml-merge, package-jpa21-model, package-xml-extended, package-validation-failed, package-jpa-advanced-field-access, package-jpa-advanced-properties, package-jpa-pu_with_spaces, package-partitioned, package-plsql, package-jpa-performance, package-jpa-performance2, package-cascade-deletes, package-jpa-metamodel, package-delimited, package-beanvalidation,
package-composite-advanced, package-composite-advanced-member_1, package-composite-advanced-member_2, package-composite-advanced-member_3,
package-xml-composite-advanced, package-xml-composite-advanced-member_1, package-xml-composite-advanced-member_2, package-xml-composite-advanced-member_3,
- package-xml-extended-composite-advanced, package-xml-extended-composite-advanced-member_1, package-xml-extended-composite-advanced-member_2, package-xml-extended-composite-advanced-member_3, package-extensibility, package-jpa-remote" description="build EclipseLink jar">
+ package-xml-extended-composite-advanced, package-xml-extended-composite-advanced-member_1, package-xml-extended-composite-advanced-member_2, package-xml-extended-composite-advanced-member_3, package-extensibility, package-jpa-remote, package-xml-mapping-metadata-complete" description="build EclipseLink jar">
<jar jarfile="${jpatest.basedir}/${jpatest.framework.jar}">
<fileset dir="${jpatest.basedir}/${classes.dir}" includes="org/eclipse/persistence/testing/framework/**/*.class"/>
</jar>
@@ -863,6 +865,29 @@
</fileset>
</jar>
</target>
+
+ <target name="package-xml-mapping-metadata-complete" depends="">
+ <copy todir="${jpatest.basedir}/${build.dir}/${eclipselink.xml.mapping.metadata.complete}/META-INF">
+ <fileset dir="${jpatest.basedir}/resource/${eclipselink.xml.mapping.metadata.complete}" includes="*.xml"/>
+ </copy>
+ <copy todir="${jpatest.basedir}/${build.dir}/${eclipselink.xml.mapping.metadata.complete}/">
+ <fileset dir="${jpatest.basedir}/resource/${eclipselink.xml.mapping.metadata.complete}" includes="org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/*"/>
+ </copy>
+ <copy todir="${jpatest.basedir}/${build.dir}/${eclipselink.xml.mapping.metadata.complete}">
+ <fileset dir="${jpatest.basedir}/${classes.dir}"
+ includes="org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/**"/>
+ </copy>
+ <antcall target="prepare-spring-xmls" inheritRefs="true">
+ <param name="MODEL_NAME" value="${eclipselink.xml.mapping.metadata.complete}"/>
+ </antcall>
+ <antcall target="prepare-osgi-xmls" inheritRefs="true">
+ <param name="MODEL_NAME" value="${eclipselink.xml.mapping.metadata.complete}"/>
+ </antcall>
+ <jar jarfile="${jpatest.basedir}/${eclipselink.xml.mapping.metadata.complete}.jar">
+ <fileset dir="${jpatest.basedir}/${build.dir}/${eclipselink.xml.mapping.metadata.complete}">
+ </fileset>
+ </jar>
+ </target>
<target name="package-ddl" depends="">
<copy todir="${jpatest.basedir}/${build.dir}/${eclipselink.ddl.generation.model}/META-INF">
@@ -1376,6 +1401,7 @@
<pathelement path="${jpatest.basedir}/${eclipselink.xml.composite.advanced.model.member_2}.jar"/>
<pathelement path="${jpatest.basedir}/${eclipselink.xml.composite.advanced.model.member_3}.jar"/>
<pathelement path="${jpatest.basedir}/eclipselink-remote.jar"/>
+ <pathelement path="${jpatest.basedir}/${eclipselink.xml.mapping.metadata.complete}.jar"/>
</path>
<path id="jpa21.run.classpath">
<pathelement path="${jpatest.basedir}/${classes.dir}"/>
@@ -1410,6 +1436,7 @@
<pathelement path="${jpatest.basedir}/${eclipselink.xml.composite.advanced.model.member_2}.jar"/>
<pathelement path="${jpatest.basedir}/${eclipselink.xml.composite.advanced.model.member_3}.jar"/>
<pathelement path="${jpatest.basedir}/eclipselink-remote.jar"/>
+ <pathelement path="${jpatest.basedir}/${eclipselink.xml.mapping.metadata.complete}.jar"/>
</path>
<path id="run.bean.validation.classpath">
<path refid="run.classpath"/>
@@ -1744,6 +1771,7 @@
<pathelement path="${jpatest.basedir}/${classes.dir}"/>
<pathelement path="${jpatest.basedir}/${jpatest.framework.jar}"/>
<pathelement path="${jpatest.basedir}/${jpa.test.jar}"/>
+ <pathelement path="${jpatest.basedir}/woven-${eclipselink.xml.mapping.metadata.complete}.jar"/>
<path refid="compile.path"/>
</path>
<path id="run.extended.classpath.static">
@@ -2395,6 +2423,14 @@
<path refid="run.extended.classpath"/>
</classpath>
</weave>
+
+ <weave source= "${jpatest.basedir}/${eclipselink.xml.mapping.metadata.complete}.jar"
+ target = "${jpatest.basedir}/woven-${eclipselink.xml.mapping.metadata.complete}.jar"
+ loglevel="${logging.level}">
+ <classpath>
+ <path refid="run.classpath"/>
+ </classpath>
+ </weave>
</target>
<target name="run-weaver-server-test">
diff --git a/jpa/eclipselink.jpa.test/resource/eclipselink-xml-mapping-metadata-complete/ecl-xml-mapping-metadata-complete-mappings.xml b/jpa/eclipselink.jpa.test/resource/eclipselink-xml-mapping-metadata-complete/ecl-xml-mapping-metadata-complete-mappings.xml
new file mode 100644
index 0000000..fc0e301
--- /dev/null
+++ b/jpa/eclipselink.jpa.test/resource/eclipselink-xml-mapping-metadata-complete/ecl-xml-mapping-metadata-complete-mappings.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity-mappings version="1.0"
+ 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 orm_1_0.xsd">
+ <persistence-unit-metadata>
+ <xml-mapping-metadata-complete/>
+ </persistence-unit-metadata>
+
+ <entity name="XMLOnlyEntity" class="org.eclipse.persistence.testing.models.jpa.xml.xmlmetadatacomplete.XMLOnlyEntity">
+ <attributes>
+ <id name="id"/>
+ <basic name="strData"/>
+ </attributes>
+ </entity>
+</entity-mappings> \ No newline at end of file
diff --git a/jpa/eclipselink.jpa.test/resource/eclipselink-xml-mapping-metadata-complete/persistence.xml b/jpa/eclipselink.jpa.test/resource/eclipselink-xml-mapping-metadata-complete/persistence.xml
new file mode 100644
index 0000000..77c517c
--- /dev/null
+++ b/jpa/eclipselink.jpa.test/resource/eclipselink-xml-mapping-metadata-complete/persistence.xml
@@ -0,0 +1,10 @@
+<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 persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="ecl-xml-mapping-metadata-complete" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <mapping-file>META-INF/ecl-xml-mapping-metadata-complete-mappings.xml</mapping-file>
+ <class>org.eclipse.persistence.testing.models.jpa.xml.xmlmetadatacomplete.AnnotationOnlyEntity</class>
+ </persistence-unit>
+</persistence>
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/AnnotationOnlyEntity.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/AnnotationOnlyEntity.java
new file mode 100644
index 0000000..69b1f50
--- /dev/null
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/AnnotationOnlyEntity.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2014 IBM Corporation 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.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * 08/18/2014-2.5 Jody Grassel (IBM Corporation)
+ * - 440802: xml-mapping-metadata-complete does not exclude @Entity annotated entities
+ ******************************************************************************/
+
+package org.eclipse.persistence.testing.models.jpa.xml.xmlmetadatacomplete;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * Entity defined only by annotation. Should be completely ignored in xml-mapping-metadata-complete PU's.
+ *
+ * @author jgrassel
+ *
+ */
+@Entity
+@Table(name="ANOONLYENT")
+public class AnnotationOnlyEntity {
+ @Id
+ private int id;
+
+ private String strData;
+
+ public AnnotationOnlyEntity() {
+
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getStrData() {
+ return strData;
+ }
+
+ public void setStrData(String strData) {
+ this.strData = strData;
+ }
+
+ @Override
+ public String toString() {
+ return "AnnotationOnlyEntity [id=" + id + ", strData=" + strData + "]";
+ }
+}
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/XLMMappingMetadataCompleteTableManager.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/XLMMappingMetadataCompleteTableManager.java
new file mode 100644
index 0000000..7f2dcf1
--- /dev/null
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/XLMMappingMetadataCompleteTableManager.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2014 IBM Corporation 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.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * 08/18/2014-2.5 Jody Grassel (IBM Corporation)
+ * - 440802: xml-mapping-metadata-complete does not exclude @Entity annotated entities
+ ******************************************************************************/
+
+package org.eclipse.persistence.testing.models.jpa.xml.xmlmetadatacomplete;
+
+import org.eclipse.persistence.tools.schemaframework.FieldDefinition;
+import org.eclipse.persistence.tools.schemaframework.TableCreator;
+import org.eclipse.persistence.tools.schemaframework.TableDefinition;
+
+public class XLMMappingMetadataCompleteTableManager extends TableCreator {
+ public XLMMappingMetadataCompleteTableManager() {
+ setName("XMLMappingMetadataComplete");
+ addTableDefinition(buildXMLOnlyEntityTable());
+ addTableDefinition(buildAnoOnlyEntityTable());
+ }
+
+ public static TableDefinition buildXMLOnlyEntityTable() {
+ TableDefinition table = new TableDefinition();
+
+ table.setName("XMLONLYENTITY");
+
+ FieldDefinition fieldID = new FieldDefinition();
+ fieldID.setName("ID");
+ fieldID.setTypeName("NUMERIC");
+ fieldID.setSize(15);
+ fieldID.setShouldAllowNull(false);
+ fieldID.setIsPrimaryKey(true);
+ fieldID.setUnique(false);
+ fieldID.setIsIdentity(false);
+ table.addField(fieldID);
+
+ FieldDefinition fieldSTRDATA = new FieldDefinition();
+ fieldSTRDATA.setName("STRDATA");
+ fieldSTRDATA.setTypeName("VARCHAR2");
+ fieldSTRDATA.setSize(80);
+ fieldSTRDATA.setSubSize(0);
+ fieldSTRDATA.setIsPrimaryKey(false);
+ fieldSTRDATA.setIsIdentity(false);
+ fieldSTRDATA.setUnique(false);
+ fieldSTRDATA.setShouldAllowNull(true);
+ table.addField(fieldSTRDATA);
+
+ return table;
+ }
+
+ public static TableDefinition buildAnoOnlyEntityTable() {
+ TableDefinition table = new TableDefinition();
+
+ table.setName("ANOONLYENT");
+
+ FieldDefinition fieldID = new FieldDefinition();
+ fieldID.setName("ID");
+ fieldID.setTypeName("NUMERIC");
+ fieldID.setSize(15);
+ fieldID.setShouldAllowNull(false);
+ fieldID.setIsPrimaryKey(true);
+ fieldID.setUnique(false);
+ fieldID.setIsIdentity(false);
+ table.addField(fieldID);
+
+ FieldDefinition fieldSTRDATA = new FieldDefinition();
+ fieldSTRDATA.setName("STRDATA");
+ fieldSTRDATA.setTypeName("VARCHAR2");
+ fieldSTRDATA.setSize(80);
+ fieldSTRDATA.setSubSize(0);
+ fieldSTRDATA.setIsPrimaryKey(false);
+ fieldSTRDATA.setIsIdentity(false);
+ fieldSTRDATA.setUnique(false);
+ fieldSTRDATA.setShouldAllowNull(true);
+ table.addField(fieldSTRDATA);
+
+ return table;
+ }
+}
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/XMLOnlyEntity.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/XMLOnlyEntity.java
new file mode 100644
index 0000000..28e3790
--- /dev/null
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/xmlmetadatacomplete/XMLOnlyEntity.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2014 IBM Corporation 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.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * 08/18/2014-2.5 Jody Grassel (IBM Corporation)
+ * - 440802: xml-mapping-metadata-complete does not exclude @Entity annotated entities
+ ******************************************************************************/
+
+package org.eclipse.persistence.testing.models.jpa.xml.xmlmetadatacomplete;
+
+import javax.persistence.Id;
+
+/**
+ * Entity defined only by XML mapping.
+ *
+ * @author jgrassel
+ *
+ */
+public class XMLOnlyEntity {
+ private int id;
+ private String strData;
+
+ public XMLOnlyEntity() {
+
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getStrData() {
+ return strData;
+ }
+
+ public void setStrData(String strData) {
+ this.strData = strData;
+ }
+
+ @Override
+ public String toString() {
+ return "XMLOnlyEntity [id=" + id + ", strData=" + strData + "]";
+ }
+}
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/FullRegressionTestSuite.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/FullRegressionTestSuite.java
index ebaddc4..5e74444 100644
--- a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/FullRegressionTestSuite.java
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/FullRegressionTestSuite.java
@@ -19,6 +19,8 @@
* - 438177: Test M2M map
* 08/11/2014-2.5 Rick Curtis
* - 440594: Tolerate invalid NamedQuery at EntityManager creation.
+ * 08/18/2014-2.5 Jody Grassel (IBM Corporation)
+ * - 440802: xml-mapping-metadata-complete does not exclude @Entity annotated entities
******************************************************************************/
package org.eclipse.persistence.testing.tests.jpa;
@@ -112,6 +114,7 @@ import org.eclipse.persistence.testing.tests.jpa.relationships.TestKeyTypeToMany
import org.eclipse.persistence.testing.tests.jpa.validation.QueryParameterValidationTestSuite;
import org.eclipse.persistence.testing.tests.jpa.validation.ValidationTestSuite;
import org.eclipse.persistence.testing.tests.jpa.xml.EntityMappingsJUnitTestSuite;
+import org.eclipse.persistence.testing.tests.jpa.xml.xmlmetadatacomplete.XMLMappingMetadataCompleteJunitTestCase;
public class FullRegressionTestSuite extends TestSuite {
@@ -331,6 +334,9 @@ public class FullRegressionTestSuite extends TestSuite {
suite.addTest(ExtensibilityTests.suite());
fullSuite.addTest(suite);
+ // XML Mapping Metadata Complete
+ fullSuite.addTest(XMLMappingMetadataCompleteJunitTestCase.suite());
+
return fullSuite;
}
}
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/xml/xmlmetadatacomplete/XMLMappingMetadataCompleteJunitTestCase.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/xml/xmlmetadatacomplete/XMLMappingMetadataCompleteJunitTestCase.java
new file mode 100644
index 0000000..0bc4ab1
--- /dev/null
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/xml/xmlmetadatacomplete/XMLMappingMetadataCompleteJunitTestCase.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2014 IBM Corporation 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.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * 08/18/2014-2.5 Jody Grassel (IBM Corporation)
+ * - 440802: xml-mapping-metadata-complete does not exclude @Entity annotated entities
+ ******************************************************************************/
+
+package org.eclipse.persistence.testing.tests.jpa.xml.xmlmetadatacomplete;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.eclipse.persistence.sessions.DatabaseSession;
+import org.eclipse.persistence.testing.framework.junit.JUnitTestCase;
+import org.eclipse.persistence.testing.models.jpa.xml.xmlmetadatacomplete.AnnotationOnlyEntity;
+import org.eclipse.persistence.testing.models.jpa.xml.xmlmetadatacomplete.XLMMappingMetadataCompleteTableManager;
+import org.eclipse.persistence.testing.models.jpa.xml.xmlmetadatacomplete.XMLOnlyEntity;
+import org.eclipse.persistence.testing.tests.jpa.xml.relationships.EntityMappingsRelationshipsJUnitTestCase;
+
+import junit.framework.*;
+
+public class XMLMappingMetadataCompleteJunitTestCase extends JUnitTestCase {
+ private final static String puName = "ecl-xml-mapping-metadata-complete";
+
+ public XMLMappingMetadataCompleteJunitTestCase() {
+ super();
+ }
+
+ public XMLMappingMetadataCompleteJunitTestCase(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("XML Mapping Metadata Complete");
+
+ suite.addTest(new XMLMappingMetadataCompleteJunitTestCase("testSetup"));
+ suite.addTest(new XMLMappingMetadataCompleteJunitTestCase("testEntityByAnnotationOnlyIsIgnored"));
+ suite.addTest(new XMLMappingMetadataCompleteJunitTestCase("testEntityByXML"));
+
+ return suite;
+ }
+
+ /**
+ * The setup is done as a test, both to record its failure, and to allow execution in the server.
+ */
+ public void testSetup() {
+ DatabaseSession session = JUnitTestCase.getServerSession();
+ new XLMMappingMetadataCompleteTableManager().replaceTables(session);
+ clearCache();
+ }
+
+ public void testEntityByAnnotationOnlyIsIgnored() {
+ EntityManager em = createEntityManager(puName);
+ try {
+ beginTransaction(em);
+
+ AnnotationOnlyEntity anoOnlyEnt = new AnnotationOnlyEntity();
+ anoOnlyEnt.setId(1);
+ anoOnlyEnt.setStrData("Some String");
+
+ try {
+ em.persist(anoOnlyEnt);
+ fail("AnnotationOnlyEntity should not be a valid entity type.");
+ } catch (Throwable t) {
+ // Expected
+ }
+ } finally {
+ if (em != null) {
+ if (isTransactionActive(em)) {
+ rollbackTransaction(em);;
+ }
+ em.close();
+ }
+ }
+ }
+
+ public void testEntityByXML() {
+ EntityManager em = createEntityManager(puName);
+ try {
+ beginTransaction(em);
+
+ XMLOnlyEntity xmlOnlyEnt = new XMLOnlyEntity();
+ xmlOnlyEnt.setId(1);
+ xmlOnlyEnt.setStrData("Some String");
+
+ // Expecting this to persist successfully
+ em.persist(xmlOnlyEnt);
+
+ commitTransaction(em);
+
+ em.clear();
+ this.clearCache();
+
+ XMLOnlyEntity xmlOnlyEnt_find = em.find(XMLOnlyEntity.class, 1);
+ assertNotNull(xmlOnlyEnt_find);
+ assertNotSame(xmlOnlyEnt, xmlOnlyEnt_find);
+ } finally {
+ if (em != null) {
+ if (isTransactionActive(em)) {
+ rollbackTransaction(em);;
+ }
+ em.close();
+ }
+ }
+ }
+}
diff --git a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProcessor.java b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProcessor.java
index 3098db0..a9ad74b 100644
--- a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProcessor.java
+++ b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 Oracle and/or its affiliates, IBM Corporation. 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.
@@ -31,6 +31,8 @@
* - 350487: JPA 2.1 Specification defined support for Stored Procedure Calls
* 10/09/2012-2.5 Guy Pelletier
* - 374688: JPA 2.1 Converter support
+ * 08/18/2014-2.5 Jody Grassel (IBM Corporation)
+ * - 440802: xml-mapping-metadata-complete does not exclude @Entity annotated entities
******************************************************************************/
package org.eclipse.persistence.internal.jpa.metadata;
@@ -314,6 +316,12 @@ public class MetadataProcessor {
// This will override any global settings.
embeddable.getEntityMappings().processEntityMappingsDefaults(embeddable);
}
+
+ // Check if the xml-mapping-metadata-complete was declared. If so, then ignore <class> entries defined
+ // in the persistence unit, as by definition only elements declared in ORM XML are to be permitted.
+ if (m_project.getPersistenceUnitMetadata() != null && m_project.getPersistenceUnitMetadata().isXMLMappingMetadataComplete()) {
+ return;
+ }
// 4 - Iterate through the classes that are referenced from the
// persistence.xml file.