openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r727649 - in /openjpa/trunk: openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java
Date Thu, 18 Dec 2008 05:44:44 GMT
Author: faywang
Date: Wed Dec 17 21:44:44 2008
New Revision: 727649

URL: http://svn.apache.org/viewvc?rev=727649&view=rev
Log:
OPENJPA-782: adding element-collection and collection-table
support for XML Serializer

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java?rev=727649&r1=727648&r2=727649&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java
Wed Dec 17 21:44:44 2008
@@ -39,6 +39,7 @@
 import org.apache.openjpa.jdbc.meta.MappingRepository;
 import org.apache.openjpa.jdbc.meta.QueryResultMapping;
 import org.apache.openjpa.jdbc.meta.SequenceMapping;
+import org.apache.openjpa.jdbc.meta.ValueMappingImpl;
 import org.apache.openjpa.jdbc.meta.ValueMappingInfo;
 import org.apache.openjpa.jdbc.meta.strats.EnumValueHandler;
 import org.apache.openjpa.jdbc.meta.strats.FlatClassStrategy;
@@ -392,6 +393,27 @@
                     endElement("join-table");
                 }
                 return;
+            case ELEM_COLL:
+                if (field.getMappingInfo().hasSchemaComponents()
+                    || field.getElementMapping().getValueInfo()
+                    .hasSchemaComponents()) {
+                    String table = field.getMappingInfo().getTableName();
+                    if (table != null) {
+                        int index = table.indexOf('.');
+                        if (index < 0)
+                            addAttribute("name", table);
+                        else {
+                            addAttribute("schema", table.substring(0, index));
+                            addAttribute("name", table.substring(index + 1));
+                        }
+                    }
+                    startElement("collection-table");
+                    ValueMappingImpl elem = (ValueMappingImpl) field.getElement();
+                    serializeColumns(elem.getValueInfo(), ColType.COL,
+                            null);
+                    endElement("collection-table");
+                }
+                return;
         }
 
         serializeColumns(field.getValueInfo(), ColType.COL,

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java?rev=727649&r1=727648&r2=727649&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java
Wed Dec 17 21:44:44 2008
@@ -919,6 +919,11 @@
                     strategy = "many-to-many";
                     cascades = fmd.getElement();
                     break;
+                case ELEM_COLL:
+                    if (isMetaDataMode())
+                        addElementCollectionAttributes(fmd);
+                    strategy = "element-collection";
+                    break;
             }
             if (isMappingMode())
                 addStrategyMappingAttributes(fmd);
@@ -1069,6 +1074,8 @@
             case JavaTypes.ARRAY:
             case JavaTypes.COLLECTION:
             case JavaTypes.MAP:
+                if (fmd.isElementCollection())
+                    return PersistenceStrategy.ELEM_COLL;
                 mappedBy = fmd.getMappedByMetaData();
                 if (mappedBy == null || mappedBy.getTypeCode() != JavaTypes.PC)
                     return PersistenceStrategy.MANY_MANY;
@@ -1134,6 +1141,16 @@
     }
 
     /**
+     * Add element-collection attributes.
+     */
+    private void addElementCollectionAttributes(FieldMetaData fmd)
+        throws SAXException {
+        if (fmd.isInDefaultFetchGroup())
+            addAttribute("fetch", "EAGER");
+        addTargetEntityAttribute(fmd);
+    }
+
+    /**
      * Add a target-entity attribute to collection and map fields that do
      * not use generics.
      */



Mime
View raw message