diff --git a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java index 2522952a6..40b0b53e0 100644 --- a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java +++ b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java @@ -26,6 +26,8 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; + import javax.persistence.DiscriminatorType; import javax.persistence.EnumType; import javax.persistence.InheritanceType; @@ -56,11 +58,13 @@ import org.apache.openjpa.jdbc.sql.DBDictionary; import org.apache.openjpa.lib.log.Log; import org.apache.openjpa.lib.meta.SourceTracker; import org.apache.openjpa.lib.util.Localizer; +import org.apache.openjpa.meta.AccessCode; import org.apache.openjpa.meta.ClassMetaData; import org.apache.openjpa.meta.FieldMetaData; import org.apache.openjpa.meta.JavaTypes; import org.apache.openjpa.persistence.XMLPersistenceMetaDataParser; import org.apache.openjpa.util.InternalException; +import org.apache.openjpa.util.MetaDataException; import org.apache.openjpa.util.UserException; import org.xml.sax.Attributes; import org.xml.sax.Locator; @@ -1390,6 +1394,27 @@ public class XMLPersistenceMappingParser } return null; } + + /** + * Process all deferred embeddables using an unknown access type. + */ + protected void addDeferredEmbeddableMetaData() { + super.addDeferredEmbeddableMetaData(); + if (_deferredMappings.size() > 0) { + Set> keys = _deferredMappings.keySet(); + Class[] classes = keys.toArray(new Class[0]); + for (int i = 0; i < classes.length; i++) { + try { + applyDeferredEmbeddableOverrides(classes[i]); + } catch (Exception e) { + throw new MetaDataException( + _loc.get("no-embeddable-metadata", + classes[i].getName()), e); + } + } + } + + } // Inner class for storing override information class DeferredEmbeddableOverrides { diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/attrOverrides/TestAssocOverridesXML.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/attrOverrides/TestAssocOverridesXML.java index 4ef3d4563..5af6e9dfa 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/attrOverrides/TestAssocOverridesXML.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/attrOverrides/TestAssocOverridesXML.java @@ -82,6 +82,9 @@ public class TestAssocOverridesXML extends AbstractPersistenceTestCase{ assertSQLFragnments(_sql, "CREATE TABLE XML_EMBALIST .*" + " .*emba_entb.*emba_mentb"); + assertSQLFragnments(_sql, "CREATE TABLE XML_EMBAMAP_1 .*" + + " .*key_emba_entb.*key_emba_mentb" + + " .*value_emba_entb.*value_emba_mentb"); } finally { try { diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/attrOverrides/XMLAssocOverEmbedB.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/attrOverrides/XMLAssocOverEmbedB.java new file mode 100644 index 000000000..f08ae2cf3 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/attrOverrides/XMLAssocOverEmbedB.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.embed.attrOverrides; + +public class XMLAssocOverEmbedB { + + private String name; + + private XMLAssocOverEntityB eb; + + private XMLAssocOverEntityB meb; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setEb(XMLAssocOverEntityB eb) { + this.eb = eb; + } + + public XMLAssocOverEntityB getEb() { + return eb; + } + + public void setMeb(XMLAssocOverEntityB meb) { + this.meb = meb; + } + + public XMLAssocOverEntityB getMeb() { + return meb; + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/attrOverrides/XMLAssocOverEntityA.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/attrOverrides/XMLAssocOverEntityA.java index ec92cabd9..bfbed7d7a 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/attrOverrides/XMLAssocOverEntityA.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/attrOverrides/XMLAssocOverEntityA.java @@ -19,12 +19,16 @@ package org.apache.openjpa.persistence.embed.attrOverrides; import java.util.List; +import java.util.Map; public class XMLAssocOverEntityA { private int id; private List embaList; + + private Map embaMap; + public void setEmbA(List embA) { this.embaList = embA; @@ -34,6 +38,14 @@ public class XMLAssocOverEntityA { return embaList; } + public void setEmbAMap(Map embAMap) { + this.embaMap = embAMap; + } + + public Map getEmbAMap() { + return embaMap; + } + public void setId(int id) { this.id = id; } diff --git a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/embed/embed-assoc-over-orm.xml b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/embed/embed-assoc-over-orm.xml index 7cf2c643a..87e3d4998 100644 --- a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/embed/embed-assoc-over-orm.xml +++ b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/embed/embed-assoc-over-orm.xml @@ -37,6 +37,21 @@ + + + + + + + + + + + + + + + @@ -69,4 +84,21 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/embed/embed-persistence.xml b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/embed/embed-persistence.xml index 0cb208bc7..914eb4234 100644 --- a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/embed/embed-persistence.xml +++ b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/embed/embed-persistence.xml @@ -23,6 +23,7 @@ org/apache/openjpa/persistence/embed/embed-assoc-over-orm.xml org.apache.openjpa.persistence.embed.attrOverrides.XMLAssocOverEmbed + org.apache.openjpa.persistence.embed.attrOverrides.XMLAssocOverEmbedB org.apache.openjpa.persistence.embed.attrOverrides.XMLAssocOverEntityA org.apache.openjpa.persistence.embed.attrOverrides.XMLAssocOverEntityB