openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r724437 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ openjpa-kernel/src/main/java/org/apache/openjpa/meta/ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ openjpa-persisten...
Date Mon, 08 Dec 2008 18:27:46 GMT
Author: faywang
Date: Mon Dec  8 10:27:45 2008
New Revision: 724437

URL: http://svn.apache.org/viewvc?rev=724437&view=rev
Log:
OPENJPA-782: embeddable support

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Coll_Embed.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Coll_Integer.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Embed.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_ToOne.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_Embed.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_ToOne.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_String.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Coll_Embed.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Coll_Integer.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Embed.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_ToMany.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_ToOne.java
Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedValueHandler.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerCollectionTableFieldStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationFieldStrategy.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceStrategy.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java?rev=724437&r1=724436&r2=724437&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java Mon Dec  8 10:27:45 2008
@@ -40,9 +40,11 @@
 import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
+import org.apache.openjpa.jdbc.meta.Embeddable;
 import org.apache.openjpa.jdbc.meta.FieldMapping;
 import org.apache.openjpa.jdbc.meta.JavaSQLTypes;
 import org.apache.openjpa.jdbc.meta.RelationId;
+import org.apache.openjpa.jdbc.meta.ValueMapping;
 import org.apache.openjpa.jdbc.meta.ValueMappingInfo;
 import org.apache.openjpa.jdbc.schema.Column;
 import org.apache.openjpa.jdbc.schema.ColumnIO;
@@ -61,9 +63,12 @@
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.FieldMetaData;
+import org.apache.openjpa.meta.JavaTypes;
 import org.apache.openjpa.meta.ValueMetaData;
+import org.apache.openjpa.util.ApplicationIds;
 import org.apache.openjpa.util.InternalException;
 import org.apache.openjpa.util.MetaDataException;
+import org.apache.openjpa.util.OpenJPAId;
 import org.apache.openjpa.util.UserException;
 
 /**
@@ -73,7 +78,8 @@
  * @since 0.4.0
  */
 public class EmbedFieldStrategy
-    extends AbstractFieldStrategy {
+    extends AbstractFieldStrategy   
+    implements Embeddable {
 
     private static final int INSERT = 0;
     private static final int UPDATE = 1;
@@ -529,6 +535,41 @@
         throws SQLException {
         throw new UserException(_loc.get("cant-project-owned", field));
     }
+    
+    /////////////////////////////
+    // Embeddable implementation
+    /////////////////////////////
+
+    public Column[] getColumns() {
+        return field.getColumns();
+    }
+
+    public ColumnIO getColumnIO() {
+        return field.getColumnIO();
+    }
+
+    public Object[] getResultArguments() {
+        return null;
+    }
+
+    public Object toEmbeddedDataStoreValue(Object val, JDBCStore store) {
+        return toDataStoreValue(val, store);
+    }
+
+    public Object toEmbeddedObjectValue(Object val) {
+        //return UNSUPPORTED;
+        return null;
+    }
+
+    public void loadEmbedded(OpenJPAStateManager sm, JDBCStore store,
+        JDBCFetchConfiguration fetch, Object val)
+        throws SQLException {
+        if (val != null)
+            sm.storeObject(field.getIndex(), val);
+        else
+            sm.storeObject(field.getIndex(), null);
+    }
+    
 
     /**
      * State manager that represents a null embedded object.

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedValueHandler.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedValueHandler.java?rev=724437&r1=724436&r2=724437&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedValueHandler.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedValueHandler.java Mon Dec  8 10:27:45 2008
@@ -19,16 +19,22 @@
 package org.apache.openjpa.jdbc.meta.strats;
 
 import java.sql.SQLException;
+import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.openjpa.enhance.PersistenceCapable;
+import org.apache.openjpa.enhance.StateManager;
 import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
+import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.Embeddable;
 import org.apache.openjpa.jdbc.meta.FieldMapping;
+import org.apache.openjpa.jdbc.meta.FieldStrategy;
 import org.apache.openjpa.jdbc.meta.ValueMapping;
 import org.apache.openjpa.jdbc.schema.Column;
 import org.apache.openjpa.jdbc.schema.ColumnIO;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
+import org.apache.openjpa.kernel.StateManagerImpl;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.MetaDataException;
 
@@ -60,12 +66,18 @@
         for (int i = 0; i < fms.length; i++) {
             if (fms[i].getManagement() != FieldMapping.MANAGE_PERSISTENT)
                 continue;
-            if (!(fms[i].getStrategy() instanceof Embeddable))
+            FieldStrategy strat = fms[i].getStrategy();
+            
+            if (!(strat instanceof Embeddable))
                 throw new MetaDataException(_loc.get("not-embeddable",
                     vm, fms[i]));
-
-            curCols = ((Embeddable) fms[i].getStrategy()).getColumns();
-            curIO = ((Embeddable) fms[i].getStrategy()).getColumnIO();
+            
+            ValueMapping val = fms[i].getValueMapping();
+            if (val.getEmbeddedMapping() != null)
+                map(val, name, io, adapt, cols, args);
+            
+            curCols = ((Embeddable) strat).getColumns();
+            curIO = ((Embeddable) strat).getColumnIO();
             for (int j = 0; j < curCols.length; j++) {
                 io.setInsertable(cols.size(), curIO.isInsertable(j, false));
                 io.setNullInsertable(cols.size(),
@@ -96,6 +108,12 @@
      * @param idx index in columns array to start
      */
     protected Object toDataStoreValue(OpenJPAStateManager em, ValueMapping vm,
+            JDBCStore store, Column[] cols, Object rval, int idx) {
+        toDataStoreValue1(em, vm, store, cols, rval, idx);
+        return rval;
+    }    
+    
+    protected int toDataStoreValue1(OpenJPAStateManager em, ValueMapping vm,
         JDBCStore store, Column[] cols, Object rval, int idx) {
         // set rest of columns from fields
         FieldMapping[] fms = vm.getEmbeddedMapping().getFieldMappings();
@@ -105,6 +123,17 @@
         for (int i = 0; i < fms.length; i++) {
             if (fms[i].getManagement() != FieldMapping.MANAGE_PERSISTENT)
                 continue;
+            
+            ValueMapping val = fms[i].getValueMapping();
+            if (val.getEmbeddedMapping() != null) {
+                cval = (em == null) ? null : em.fetch(i);
+                if (cval instanceof PersistenceCapable) {
+                    OpenJPAStateManager embedSm = (OpenJPAStateManager)
+                        ((PersistenceCapable)cval).pcGetStateManager();
+                    idx = toDataStoreValue1(embedSm, val, store, cols, rval, idx);
+                }
+            }
+            
             embed = (Embeddable) fms[i].getStrategy();
             ecols = embed.getColumns();
             if (ecols.length == 0)
@@ -121,7 +150,7 @@
                 idx += ecols.length;
             }
         }
-        return rval;
+        return idx;
     }
 
     /**
@@ -136,6 +165,13 @@
      * @param idx index in columns array to start
      */
     protected void toObjectValue(OpenJPAStateManager em, ValueMapping vm,
+            Object val, JDBCStore store, JDBCFetchConfiguration fetch,
+            Column[] cols, int idx)
+            throws SQLException {
+        toObjectValue1(em, vm, val, store, fetch, cols, idx);
+    }    
+    
+    protected int toObjectValue1(OpenJPAStateManager em, ValueMapping vm,
         Object val, JDBCStore store, JDBCFetchConfiguration fetch,
         Column[] cols, int idx)
         throws SQLException {
@@ -147,18 +183,27 @@
             if (fms[i].getManagement() != FieldMapping.MANAGE_PERSISTENT)
                 continue;
 
+            ValueMapping vm1 = fms[i].getValueMapping();
+            OpenJPAStateManager em1 = null;
+            
             embed = (Embeddable) fms[i].getStrategy();
-            ecols = embed.getColumns();
-            if (ecols.length == 0)
-                cval = null;
-            else if (idx == 0 && ecols.length == cols.length)
-                cval = val;
-            else if (ecols.length == 1)
-                cval = ((Object[]) val)[idx++];
-            else {
-                cval = new Object[ecols.length];
-                System.arraycopy(val, idx, cval, 0, ecols.length);
-                idx += ecols.length;
+            if (vm1.getEmbeddedMapping() != null) {
+                em1 = store.getContext().embed(null, null, em, vm1);
+                idx = toObjectValue1(em1, vm1, val, store, fetch, cols, idx);
+                cval = em1.getManagedInstance();
+            } else {
+                ecols = embed.getColumns();
+                if (ecols.length == 0)
+                    cval = null;
+                else if (idx == 0 && ecols.length == cols.length)
+                    cval = val;
+                else if (ecols.length == 1)
+                    cval = ((Object[]) val)[idx++];
+                else {
+                    cval = new Object[ecols.length];
+                    System.arraycopy(val, idx, cval, 0, ecols.length);
+                    idx += ecols.length;
+                }
             }
 
             if (store != null)
@@ -168,5 +213,6 @@
                 em.store(fms[i].getIndex(), cval);
             }
         }
+        return idx;
     }
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerCollectionTableFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerCollectionTableFieldStrategy.java?rev=724437&r1=724436&r2=724437&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerCollectionTableFieldStrategy.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerCollectionTableFieldStrategy.java Mon Dec  8 10:27:45 2008
@@ -97,7 +97,10 @@
             throw new MetaDataException(_loc.get("not-coll", field));
 
         assertNotMappedBy();
-        field.getValueInfo().assertNoSchemaComponents(field, !adapt);
+        // JPA2.0 allows schema for @CollectionTable(used with
+        // @ElementCollection)  
+        if (!field.isElementCollection())
+            field.getValueInfo().assertNoSchemaComponents(field, !adapt);
         field.getKeyMapping().getValueInfo().assertNoSchemaComponents
             (field.getKey(), !adapt);
 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationFieldStrategy.java?rev=724437&r1=724436&r2=724437&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationFieldStrategy.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationFieldStrategy.java Mon Dec  8 10:27:45 2008
@@ -967,7 +967,13 @@
 
         if (oid == null)
             sm.storeObject(field.getIndex(), null);
-        else
-            sm.setIntermediate(field.getIndex(), oid);
+        else {
+            if (JavaTypes.maybePC(field.getValue()) &&
+                field.getElement().getEmbeddedMetaData() == null) {
+                Object obj = store.find(oid, field, fetch);
+                sm.storeObject(field.getIndex(), obj);
+            } else    
+                sm.setIntermediate(field.getIndex(), oid);
+        }
     }
 }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java?rev=724437&r1=724436&r2=724437&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java Mon Dec  8 10:27:45 2008
@@ -209,6 +209,7 @@
     private String _orderDec = null;
     // indicate if this field is used by other field as "order by" value 
     private boolean _usedInOrderBy = false;
+    private boolean _isElementCollection = false;
 
     /**
      * Constructor.
@@ -2126,4 +2127,12 @@
     public void setValueGenerated(boolean generated) {
         this._generated = generated;
     }
+
+    public boolean isElementCollection() {
+        return _isElementCollection;
+    }
+
+    public void setElementCollection(boolean isElementCollection) {
+        this._isElementCollection = isElementCollection;
+    }
 }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java?rev=724437&r1=724436&r2=724437&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java Mon Dec  8 10:27:45 2008
@@ -32,6 +32,7 @@
 import javax.persistence.AssociationOverrides;
 import javax.persistence.AttributeOverride;
 import javax.persistence.AttributeOverrides;
+import javax.persistence.CollectionTable;
 import javax.persistence.ColumnResult;
 import javax.persistence.DiscriminatorColumn;
 import javax.persistence.DiscriminatorValue;
@@ -152,6 +153,7 @@
         _tags.put(ClassCriteria.class, CLASS_CRIT);
         _tags.put(Columns.class, COLS);
         _tags.put(ContainerTable.class, CONTAINER_TABLE);
+        _tags.put(CollectionTable.class, COLLECTION_TABLE);
         _tags.put(DataStoreIdColumn.class, DATASTORE_ID_COL);
         _tags.put(DiscriminatorStrategy.class, DISCRIM_STRAT);
         _tags.put(EagerFetchMode.class, EAGER_FETCH_MODE);
@@ -1070,6 +1072,9 @@
                 case CONTAINER_TABLE:
                     parseContainerTable(fm, (ContainerTable) anno);
                     break;
+                case COLLECTION_TABLE:
+                    parseCollectionTable(fm, (CollectionTable) anno);
+                    break;
                 case EAGER_FETCH_MODE:
                     fm.setEagerFetchMode(toEagerFetchModeConstant
                         (((EagerFetchMode) anno).value()));
@@ -1223,9 +1228,11 @@
     private void parseAttributeOverrides(FieldMapping fm,
         AttributeOverride... attrs) {
         ClassMapping embed = fm.getEmbeddedMapping();
-        if (embed == null)
-            throw new MetaDataException(_loc.get("not-embedded", fm));
-
+        if (embed == null) {
+            embed = fm.getElementMapping().getEmbeddedMapping();
+            if (embed == null)
+                throw new MetaDataException(_loc.get("not-embedded", fm));
+        }
         FieldMapping efm;
         for (AttributeOverride attr : attrs) {
             efm = embed.getFieldMapping(attr.name());
@@ -1322,7 +1329,10 @@
         	secondary = trackSecondaryTable(fm, secondary,	pcols[i].table(), i);
         }
 
-        setColumns(fm, fm.getValueInfo(), cols, unique);
+        if (fm.isElementCollection())
+            setColumns(fm, fm.getElementMapping().getValueInfo(), cols, unique);
+        else
+            setColumns(fm, fm.getValueInfo(), cols, unique);
         if (secondary != null)
             fm.getMappingInfo().setTableName(secondary);
     }
@@ -1621,6 +1631,19 @@
     }
 
     /**
+     * Parse @CollectionTable.
+     */
+    protected void parseCollectionTable(FieldMapping fm, CollectionTable ctbl) {
+        FieldMappingInfo info = fm.getMappingInfo(); 
+        info.setTableName(toTableName(ctbl.schema(),
+            ctbl.name()));
+        //ctbl.catalog()
+        parseJoinColumns(fm, fm.getMappingInfo(), false, ctbl.joinColumns());
+        addUniqueConstraints(info.getTableName(), fm.getDefiningMetaData(), 
+            info, ctbl.uniqueConstraints());
+    }
+    
+    /**
      * Parse @OrderColumn.
      */
     private void parseOrderColumn(FieldMapping fm, OrderColumn order) {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java?rev=724437&r1=724436&r2=724437&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/MappingTag.java Mon Dec  8 10:27:45 2008
@@ -61,6 +61,7 @@
     CLASS_CRIT,
     COLS,
     CONTAINER_TABLE,
+    COLLECTION_TABLE,
     DATASTORE_ID_COL,
     DISCRIM_STRAT,
     EAGER_FETCH_MODE,

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed.java?rev=724437&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed.java Mon Dec  8 10:27:45 2008
@@ -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;
+
+import javax.persistence.Embeddable;
+
+@Embeddable 
+public class Embed {
+    protected int intVal1;
+    protected int intVal2;
+    protected int intVal3;
+    
+    public int getIntVal1() {
+        return intVal1;
+    }
+    
+    public void setIntVal1(int intVal1) {
+        this.intVal1 = intVal1;
+    }
+    
+    public int getIntVal2() {
+        return intVal2;
+    }
+    
+    public void setIntVal2(int intVal2) {
+        this.intVal2 = intVal2;
+    }
+    
+    public int getIntVal3() {
+        return intVal3;
+    }
+    
+    public void setIntVal3(int intVal3) {
+        this.intVal3 = intVal3;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Coll_Embed.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Coll_Embed.java?rev=724437&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Coll_Embed.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Coll_Embed.java Mon Dec  8 10:27:45 2008
@@ -0,0 +1,77 @@
+/*
+ * 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;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+import javax.persistence.ElementCollection;
+
+@Embeddable 
+public class Embed_Coll_Embed {
+    protected int intVal1;
+    protected int intVal2;
+    protected int intVal3;
+    
+    @ElementCollection // use default table name
+    //@CollectionTable(name="TableA")
+    @AttributeOverrides({
+        @AttributeOverride(name="intVal1", column=@Column(name="A1")),
+        @AttributeOverride(name="intVal2", column=@Column(name="A2")),
+        @AttributeOverride(name="intVal3", column=@Column(name="A3"))
+    })
+    protected List<Embed> embeds = new ArrayList<Embed>();
+    
+    public int getIntVal1() {
+        return intVal1;
+    }
+    
+    public void setIntVal1(int intVal1) {
+        this.intVal1 = intVal1;
+    }
+    
+    public int getIntVal2() {
+        return intVal2;
+    }
+    
+    public void setIntVal2(int intVal2) {
+        this.intVal2 = intVal2;
+    }
+    
+    public int getIntVal3() {
+        return intVal3;
+    }
+    
+    public void setIntVal3(int intVal3) {
+        this.intVal3 = intVal3;
+    }
+        
+    public List<Embed> getEmbeds() {
+        return embeds;
+    }
+ 
+    public void addEmbed(Embed embed) {
+        embeds.add(embed);
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Coll_Integer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Coll_Integer.java?rev=724437&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Coll_Integer.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Coll_Integer.java Mon Dec  8 10:27:45 2008
@@ -0,0 +1,67 @@
+/*
+ * 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;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.Embeddable;
+import javax.persistence.ElementCollection;
+
+@Embeddable 
+public class Embed_Coll_Integer {
+    protected int intVal1;
+    protected int intVal2;
+    protected int intVal3;
+    
+    @ElementCollection // use default table name
+    //@CollectionTable
+    protected Set<Integer> otherIntVals = new HashSet<Integer>();
+    
+    public int getIntVal1() {
+        return intVal1;
+    }
+    
+    public void setIntVal1(int intVal1) {
+        this.intVal1 = intVal1;
+    }
+    
+    public int getIntVal2() {
+        return intVal2;
+    }
+    
+    public void setIntVal2(int intVal2) {
+        this.intVal2 = intVal2;
+    }
+    
+    public int getIntVal3() {
+        return intVal3;
+    }
+    
+    public void setIntVal3(int intVal3) {
+        this.intVal3 = intVal3;
+    }
+        
+    public Set<Integer> getOtherIntVals() {
+        return otherIntVals;
+    }
+ 
+    public void addOtherIntVal(int intVal) {
+        otherIntVals.add(intVal);
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Embed.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Embed.java?rev=724437&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Embed.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_Embed.java Mon Dec  8 10:27:45 2008
@@ -0,0 +1,71 @@
+/*
+ * 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;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+import javax.persistence.Embedded;
+
+@Embeddable 
+public class Embed_Embed {
+    protected int intVal1;
+    protected int intVal2;
+    protected int intVal3;
+    
+    @Embedded
+    @AttributeOverrides({ 
+        @AttributeOverride(name="intVal1", column=@Column(name="IntVal1x")), 
+        @AttributeOverride(name="intVal2", column=@Column(name="IntVal2x")), 
+        @AttributeOverride(name="intVal3", column=@Column(name="IntVal3x")) })
+    protected Embed embed;
+    
+    public int getIntVal1() {
+        return intVal1;
+    }
+    
+    public void setIntVal1(int intVal1) {
+        this.intVal1 = intVal1;
+    }
+    
+    public int getIntVal2() {
+        return intVal2;
+    }
+    
+    public void setIntVal2(int intVal2) {
+        this.intVal2 = intVal2;
+    }
+    
+    public int getIntVal3() {
+        return intVal3;
+    }
+    
+    public void setIntVal3(int intVal3) {
+        this.intVal3 = intVal3;
+    }
+        
+    public Embed getEmbed() {
+        return embed;
+    }
+ 
+    public void setEmbed(Embed embed) {
+        this.embed = embed;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_ToOne.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_ToOne.java?rev=724437&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_ToOne.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_ToOne.java Mon Dec  8 10:27:45 2008
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import javax.persistence.Embeddable;
+import javax.persistence.OneToOne;
+
+@Embeddable 
+public class Embed_ToOne {
+    protected String name1;
+    protected String name2;
+    protected String name3;
+    @OneToOne
+    protected EntityB1 b;
+    
+    public String getName1() {
+        return name1;
+    }
+    
+    public void setName1(String name1) {
+        this.name1 = name1;
+    }
+    
+    public String getName2() {
+        return name2;
+    }
+    
+    public void setName2(String name2) {
+        this.name2 = name2;
+    }
+    
+    public String getName3() {
+        return name3;
+    }
+    
+    public void setName3(String name3) {
+        this.name3 = name3;
+    }
+    
+    public void setEntityB(EntityB1 b) {
+        this.b = b;
+    }
+    
+    public EntityB1 getEntityB() {
+        return b;
+    }
+    
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_Embed.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_Embed.java?rev=724437&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_Embed.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_Embed.java Mon Dec  8 10:27:45 2008
@@ -0,0 +1,79 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+
+import javax.persistence.ElementCollection;
+
+@Entity
+public class EntityA_Coll_Embed_Embed implements Serializable {
+    @Id
+    Integer id;
+
+    @Column(length=30)
+    String name;
+    
+    @Basic(fetch=FetchType.LAZY)
+    int age;
+
+    @ElementCollection
+    protected List<Embed_Embed> embeds = new ArrayList<Embed_Embed>();
+    
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public List<Embed_Embed> getEmbeds() {
+        return embeds;
+    }
+    
+    public void addEmbed(Embed_Embed embed) {
+        embeds.add(embed);
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_ToOne.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_ToOne.java?rev=724437&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_ToOne.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_ToOne.java Mon Dec  8 10:27:45 2008
@@ -0,0 +1,94 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+
+import javax.persistence.ElementCollection;
+import javax.persistence.CollectionTable;
+
+@Entity
+public class EntityA_Coll_Embed_ToOne implements Serializable {
+    // contains a collection of Embed1ToOne
+    // Embed1ToOne does not have an element collection or to-Many relationships
+    @Id
+    Integer id;
+
+    @Column(length=30)
+    String name;
+    
+    @Basic(fetch=FetchType.LAZY)
+    int age;
+
+    //@PersistentCollection(elementEmbedded=true)
+    //@ContainerTable
+    
+    @ElementCollection(fetch=FetchType.EAGER)
+    @CollectionTable(name="EMBED1ToOneS2") // use default join column name
+    @AttributeOverrides({
+        @AttributeOverride(name="name1", column=@Column(name="EMB_NAME1")),
+        @AttributeOverride(name="name2", column=@Column(name="EMB_NAME2")),
+        @AttributeOverride(name="name3", column=@Column(name="EMB_NAME3"))
+    })
+
+    protected Set<Embed_ToOne> embed1s = new HashSet<Embed_ToOne>();
+     
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Set<Embed_ToOne> getEmbed1ToOnes() {
+        return embed1s;
+    }
+    
+    public void addEmbed1ToOne(Embed_ToOne embed1) {
+        embed1s.add(embed1);
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_String.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_String.java?rev=724437&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_String.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_String.java Mon Dec  8 10:27:45 2008
@@ -0,0 +1,82 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+
+import javax.persistence.ElementCollection;
+import javax.persistence.CollectionTable;
+
+@Entity
+public class EntityA_Coll_String implements Serializable {
+    @Id
+    Integer id;
+
+    @Column(length=30)
+    String name;
+    
+    @Basic(fetch=FetchType.LAZY)
+    int age;
+
+    @ElementCollection // use default table (BasicA_NICKNAMES)
+    @CollectionTable(name="NickNames_Tbl")
+    @Column(name="nicknames1", length=20)
+    protected Set<String> nickNames = new HashSet<String>();
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Set<String> getNickNames() {
+        return nickNames;
+    }
+    
+    public void addNickName(String nickName) {
+        nickNames.add(nickName);
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Coll_Embed.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Coll_Embed.java?rev=724437&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Coll_Embed.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Coll_Embed.java Mon Dec  8 10:27:45 2008
@@ -0,0 +1,82 @@
+/*
+ * 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;
+import java.io.Serializable;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+
+@Entity
+public class EntityA_Embed_Coll_Embed implements Serializable {
+    @Id
+    Integer id;
+
+    @Column(length=30)
+    String name;
+    
+    @Basic(fetch=FetchType.LAZY)
+    int age;
+
+    @Embedded
+    @AttributeOverrides({
+        @AttributeOverride(name="intVal1", column=@Column(name="A1")),
+        @AttributeOverride(name="intVal2", column=@Column(name="A2")),
+        @AttributeOverride(name="intVal3", column=@Column(name="A3"))
+    })
+    protected Embed_Coll_Embed embed;
+    
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Embed_Coll_Embed getEmbed() {
+        return embed;
+    }
+    
+    public void setEmbed(Embed_Coll_Embed embed) {
+        this.embed = embed;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Coll_Integer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Coll_Integer.java?rev=724437&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Coll_Integer.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Coll_Integer.java Mon Dec  8 10:27:45 2008
@@ -0,0 +1,74 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+
+@Entity
+public class EntityA_Embed_Coll_Integer implements Serializable {
+    @Id
+    Integer id;
+
+    @Column(length=30)
+    String name;
+    
+    @Basic(fetch=FetchType.LAZY)
+    int age;
+
+    protected Embed_Coll_Integer embed;
+    
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Embed_Coll_Integer getEmbed() {
+        return embed;
+    }
+    
+    public void setEmbed(Embed_Coll_Integer embed) {
+        this.embed = embed;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Embed.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Embed.java?rev=724437&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Embed.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_Embed.java Mon Dec  8 10:27:45 2008
@@ -0,0 +1,75 @@
+/*
+ * 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;
+import java.io.Serializable;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+
+@Entity
+public class EntityA_Embed_Embed implements Serializable {
+    @Id
+    Integer id;
+
+    @Column(length=30)
+    String name;
+    
+    @Basic(fetch=FetchType.LAZY)
+    int age;
+
+    @Embedded
+    protected Embed_Embed embed;
+    
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Embed_Embed getEmbed() {
+        return embed;
+    }
+    
+    public void setEmbed(Embed_Embed embed) {
+        this.embed = embed;
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_ToMany.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_ToMany.java?rev=724437&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_ToMany.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_ToMany.java Mon Dec  8 10:27:45 2008
@@ -0,0 +1,75 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+
+@Entity
+public class EntityA_Embed_ToMany implements Serializable {
+    @Id
+    Integer id;
+
+    @Column(length = 30)
+    String name;
+
+    @Basic(fetch = FetchType.LAZY)
+    int age;
+
+    @Embedded
+    protected Embed_ToMany embed;
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Embed_ToMany getEmbed() {
+        return embed;
+    }
+
+    public void setEmbed(Embed_ToMany embed) {
+        this.embed = embed;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_ToOne.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_ToOne.java?rev=724437&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_ToOne.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Embed_ToOne.java Mon Dec  8 10:27:45 2008
@@ -0,0 +1,75 @@
+/*
+ * 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;
+import java.io.Serializable;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+
+@Entity
+public class EntityA_Embed_ToOne implements Serializable {
+    @Id
+    Integer id;
+
+    @Column(length=30)
+    String name;
+    
+    @Basic(fetch=FetchType.LAZY)
+    int age;
+
+    @Embedded
+    protected Embed_ToOne embed;
+    
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Embed_ToOne getEmbed() {
+        return embed;
+    }
+    
+    public void setEmbed(Embed_ToOne embed) {
+        this.embed = embed;
+    }
+}
+

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.java?rev=724437&r1=724436&r2=724437&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.java Mon Dec  8 10:27:45 2008
@@ -19,6 +19,7 @@
 package org.apache.openjpa.persistence.embed;
 
 import java.util.List;
+import java.util.Set;
 
 import javax.persistence.EntityManager;
 import javax.persistence.EntityTransaction;
@@ -27,13 +28,46 @@
 import org.apache.openjpa.persistence.test.SingleEMFTestCase;
 
 public class TestEmbeddable extends SingleEMFTestCase {
+   
+    public int numEmbeddables = 1;
+    public int numBasicTypes = 1;
     public int ID = 1;
 
     public void setUp() {
-        setUp(Embed_Embed_ToMany.class, Embed_ToMany.class, 
-            EntityA_Embed_Embed_ToMany.class, EntityB1.class, 
+        setUp(Embed.class, Embed_Coll_Embed.class, Embed_Coll_Integer.class, 
+            Embed_Embed.class, Embed_Embed_ToMany.class, Embed_ToMany.class, 
+            Embed_ToOne.class, EntityA_Coll_Embed_ToOne.class, 
+            EntityA_Coll_String.class, EntityA_Embed_Coll_Embed.class, 
+            EntityA_Embed_Coll_Integer.class, EntityA_Embed_Embed.class, 
+            EntityA_Embed_Embed_ToMany.class, EntityA_Embed_ToMany.class, 
+            EntityA_Embed_ToOne.class, EntityB1.class, 
+            EntityA_Coll_Embed_Embed.class,
             CLEAR_TABLES);
     }
+    
+    public void testEntityA_Coll_String() {
+        createEntityA_Coll_String();
+        queryEntityA_Coll_String();
+        findEntityA_Coll_String();
+    }
+
+    public void testEntityA_Embed_ToOne() {
+        createEntityA_Embed_ToOne();
+        queryEntityA_Embed_ToOne();
+        findEntityA_Embed_ToOne();
+    }
+
+    public void testEntityA_Coll_Embed_ToOne() {
+        createEntityA_Coll_Embed_ToOne();
+        queryEntityA_Coll_Embed_ToOne();
+        findEntityA_Coll_Embed_ToOne();
+    }
+
+    public void testEntityA_Embed_ToMany() {
+        createEntityA_Embed_ToMany();
+        queryEntityA_Embed_ToMany();
+        findEntityA_Embed_ToMany();
+    }
 
     public void testEntityA_Embed_Embed_ToMany() {
         createEntityA_Embed_Embed_ToMany();
@@ -41,12 +75,146 @@
         findEntityA_Embed_Embed_ToMany();
     }
 
+    public void testEntityA_Embed_Coll_Integer() {
+        createEntityA_Embed_Coll_Integer();
+        queryEntityA_Embed_Coll_Integer();
+        findEntityA_Embed_Coll_Integer();
+    }
+
+    public void testEntityA_Embed_Embed() {
+        createEntityA_Embed_Embed();
+        queryEntityA_Embed_Embed();
+        findEntityA_Embed_Embed();
+    }
+
+    public void atestEntityA_Coll_Embed_Embed() {
+        createEntityA_Coll_Embed_Embed();
+        queryEntityA_Coll_Embed_Embed();
+        findEntityA_Coll_Embed_Embed();
+    }
+
+    public void testEntityA_Embed_Coll_Embed() {
+        createEntityA_Embed_Coll_Embed();
+        queryEntityA_Embed_Coll_Embed();
+        findEntityA_Embed_Coll_Embed();
+    }
+
+    /*
+     * Create EntityA_Coll_String
+     */
+    public void createEntityA_Coll_String() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        createEntityA_Coll_String(em, ID);
+        tran.begin();
+        em.flush();
+        tran.commit();
+        em.close();
+    }
+
+    public void createEntityA_Coll_String(EntityManager em, int id) {
+        EntityA_Coll_String a = new EntityA_Coll_String();
+        a.setId(id);
+        a.setName("a" + id);
+        a.setAge(id);
+        for (int i = 0; i < numBasicTypes; i++)
+            a.addNickName("nickName_" + id + i);
+        em.persist(a);
+    }
+
+    /*
+     * Create EntityA_Embed_ToOne
+     */
+    public void createEntityA_Embed_ToOne() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        createEntityA_Embed_ToOne(em, ID);
+        tran.begin();
+        em.flush();
+        tran.commit();
+        em.close();
+    }
+
+    public void createEntityA_Embed_ToOne(EntityManager em, int id) {
+        EntityA_Embed_ToOne a = new EntityA_Embed_ToOne();
+        a.setId(id);
+        a.setName("a" + id);
+        a.setAge(id);
+        Embed_ToOne embed = createEmbed_ToOne(em, id);
+        a.setEmbed(embed);
+        em.persist(a);
+    }
+
+    public Embed_ToOne createEmbed_ToOne(EntityManager em, int id) {
+        Embed_ToOne embed = new Embed_ToOne();
+        embed.setName1("name1");
+        embed.setName2("name2");
+        embed.setName3("name3");
+        EntityB1 b = new EntityB1();
+        b.setId(id);
+        b.setName("b" + id);
+        embed.setEntityB(b);
+        em.persist(b);
+        return embed;
+    }
+
+    /*
+     * Create EntityA_Coll_Embed_ToOne
+     */
+    public void createEntityA_Coll_Embed_ToOne() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        createEntityA_Coll_Embed_ToOne(em, ID);
+        tran.begin();
+        em.flush();
+        tran.commit();
+        em.close();
+    }
+
+    public void createEntityA_Coll_Embed_ToOne(EntityManager em, int id) {
+        EntityA_Coll_Embed_ToOne a = new EntityA_Coll_Embed_ToOne();
+        a.setId(id);
+        a.setName("a" + id);
+        a.setAge(id);
+        for (int i = 0; i < numEmbeddables; i++) {
+            Embed_ToOne embed = createEmbed_ToOne(em, i+id);
+            EntityB1 b = new EntityB1();
+            b.setId(id + i);
+            b.setName("b" + id + i);
+            a.addEmbed1ToOne(embed);
+        }
+        em.persist(a);
+    }
+
+    /*
+     * Create EntityA_Embed_ToMany
+     */
+    public void createEntityA_Embed_ToMany() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        createEntityA_Embed_ToMany(em, ID);
+        tran.begin();
+        em.flush();
+        tran.commit();
+        em.close();
+    }
+
+    public void createEntityA_Embed_ToMany(EntityManager em, int id) {
+        EntityA_Embed_ToMany a = new EntityA_Embed_ToMany();
+        a.setId(id);
+        a.setName("a" + id);
+        a.setAge(id);
+        Embed_ToMany embed = createEmbed_ToMany(em, id);
+        a.setEmbed(embed);
+        em.persist(a);
+    }
+
     public Embed_ToMany createEmbed_ToMany(EntityManager em, int id) {
         Embed_ToMany embed = new Embed_ToMany();
         embed.setName1("name1");
         embed.setName2("name2");
         embed.setName3("name3");
-        for (int i = 0; i < 1; i++) {
+        for (int i = 0; i < numEmbeddables; i++) {
             EntityB1 b = new EntityB1();
             b.setId(id + i);
             b.setName("b" + id + i);
@@ -90,6 +258,181 @@
     }
     
     /*
+     * Create EntityA_Embed_Coll_Integer
+     */
+    public void createEntityA_Embed_Coll_Integer() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        createEntityA_Embed_Coll_Integer(em, ID);
+        tran.begin();
+        em.flush();
+        tran.commit();
+        em.close();
+    }
+
+    public void createEntityA_Embed_Coll_Integer(EntityManager em, int id) {
+        EntityA_Embed_Coll_Integer a = new EntityA_Embed_Coll_Integer();
+        a.setId(id);
+        a.setName("a" + id);
+        a.setAge(id);
+        Embed_Coll_Integer embed = createEmbed_Coll_Integer(em, id);
+        a.setEmbed(embed);
+        em.persist(a);
+    }
+
+    public Embed_Coll_Integer createEmbed_Coll_Integer(EntityManager em, int id) {
+        Embed_Coll_Integer embed = new Embed_Coll_Integer();
+        embed.setIntVal1(id*10 + 1);
+        embed.setIntVal2(id*10 + 2);
+        embed.setIntVal3(id*10 + 3);
+        for (int i = 0; i < numBasicTypes; i++) {
+            embed.addOtherIntVal(id * 100 + i);
+        }
+        return embed;
+    }
+
+    /*
+     * Create EntityA_Embed_Embed
+     */
+    public void createEntityA_Embed_Embed() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        createEntityA_Embed_Embed(em, ID);
+        tran.begin();
+        em.flush();
+        tran.commit();
+        em.close();
+    }
+
+    public void createEntityA_Embed_Embed(EntityManager em, int id) {
+        EntityA_Embed_Embed a = new EntityA_Embed_Embed();
+        a.setId(id);
+        a.setName("a" + id);
+        a.setAge(id);
+        Embed_Embed embed = createEmbed_Embed(em, id, 0);
+        a.setEmbed(embed);
+        em.persist(a);
+    }
+
+    public Embed_Embed createEmbed_Embed(EntityManager em, int id, int idx) {
+        Embed_Embed embed = new Embed_Embed();
+        embed.setIntVal1(id * 100 + idx * 10 + 1);
+        embed.setIntVal2(id * 100 + idx * 10 + 2);
+        embed.setIntVal3(id * 100 + idx * 10 + 3);
+        Embed embed1 = createEmbed(id, idx);
+        embed.setEmbed(embed1);
+        return embed;
+    }
+
+    public Embed createEmbed(int id, int idx) {
+        Embed embed = new Embed();
+        embed.setIntVal1(id * 100 + idx * 10 + 4);
+        embed.setIntVal2(id * 100 + idx * 10 + 5);
+        embed.setIntVal3(id * 100 + idx * 10 + 6);
+        return embed;
+    }
+
+    /*
+     * Create EntityA_Coll_Embed_Embed
+     */
+    public void createEntityA_Coll_Embed_Embed() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        createEntityA_Coll_Embed_Embed(em, ID);
+        tran.begin();
+        em.flush();
+        tran.commit();
+        em.close();
+    }
+
+    public void createEntityA_Coll_Embed_Embed(EntityManager em, int id) {
+        EntityA_Coll_Embed_Embed a = new EntityA_Coll_Embed_Embed();
+        a.setId(id);
+        a.setName("a" + id);
+        a.setAge(id);
+        for (int i = 0; i < numEmbeddables; i++) {
+            Embed_Embed embed = createEmbed_Embed(em, id, i);
+            a.addEmbed(embed);
+        }
+        em.persist(a);
+    }
+
+    /*
+     * Create EntityA_Embed_Coll_Embed
+     */
+    public void createEntityA_Embed_Coll_Embed() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        createEntityA_Embed_Coll_Embed(em, ID);
+        tran.begin();
+        em.flush();
+        tran.commit();
+        em.close();
+    }
+
+    public void createEntityA_Embed_Coll_Embed(EntityManager em, int id) {
+        EntityA_Embed_Coll_Embed a = new EntityA_Embed_Coll_Embed();
+        a.setId(id);
+        a.setName("a" + id);
+        a.setAge(id);
+        Embed_Coll_Embed embed = createEmbed_Coll_Embed(em, id);
+        a.setEmbed(embed);
+        em.persist(a);
+    }
+
+    public Embed_Coll_Embed createEmbed_Coll_Embed(EntityManager em, int id) {
+        Embed_Coll_Embed embed = new Embed_Coll_Embed();
+        embed.setIntVal1(id * 10 + 1);
+        embed.setIntVal2(id * 10 + 2);
+        embed.setIntVal3(id * 10 + 3);
+        for (int i = 0; i < numEmbeddables; i++) {
+            Embed embed1 = createEmbed(id, i);
+            embed.addEmbed(embed1);
+        }
+        return embed;
+    }
+
+    /*
+     * Find EntityA_Coll_String
+     */
+    public void findEntityA_Coll_String() {
+        EntityManager em = emf.createEntityManager();
+        EntityA_Coll_String a = em.find(EntityA_Coll_String.class, ID);
+        checkEntityA_Coll_String(a);
+        em.close();
+    }
+
+    /*
+     * Find EntityA_Embed_ToOne
+     */
+    public void findEntityA_Embed_ToOne() {
+        EntityManager em = emf.createEntityManager();
+        EntityA_Embed_ToOne a = em.find(EntityA_Embed_ToOne.class, ID);
+        checkEntityA_Embed_ToOne(a);
+        em.close();
+    }
+
+    /*
+     * Find EntityA_Coll_Embed_ToOne
+     */
+    public void findEntityA_Coll_Embed_ToOne() {
+        EntityManager em = emf.createEntityManager();
+        EntityA_Coll_Embed_ToOne a = em.find(EntityA_Coll_Embed_ToOne.class, ID);
+        checkEntityA_Coll_Embed_ToOne(a);
+        em.close();
+    }
+
+    /*
+     * Find EntityA_Embed_ToMany
+     */
+    public void findEntityA_Embed_ToMany() {
+        EntityManager em = emf.createEntityManager();
+        EntityA_Embed_ToMany a = em.find(EntityA_Embed_ToMany.class, ID);
+        checkEntityA_Embed_ToMany(a);
+        em.close();
+    }
+
+    /*
      * Find EntityA_Embed_Embed_ToMany
      */
     public void findEntityA_Embed_Embed_ToMany() {
@@ -99,6 +442,116 @@
         em.close();
     }
 
+    /*
+     * Find EntityA_Embed_Coll_Integer
+     */
+    public void findEntityA_Embed_Coll_Integer() {
+        EntityManager em = emf.createEntityManager();
+        EntityA_Embed_Coll_Integer a = em.find(EntityA_Embed_Coll_Integer.class, ID);
+        checkEntityA_Embed_Coll_Integer(a);
+        em.close();
+    }
+
+    /*
+     * Find EntityA_Embed_Embed
+     */
+    public void findEntityA_Embed_Embed() {
+        EntityManager em = emf.createEntityManager();
+        EntityA_Embed_Embed a = em.find(EntityA_Embed_Embed.class, ID);
+        checkEntityA_Embed_Embed(a);
+        em.close();
+    }
+
+    /*
+     * Find EntityA_Coll_Embed_Embed
+     */
+    public void findEntityA_Coll_Embed_Embed() {
+        EntityManager em = emf.createEntityManager();
+        EntityA_Coll_Embed_Embed a = em.find(EntityA_Coll_Embed_Embed.class, ID);
+        checkEntityA_Coll_Embed_Embed(a);
+        em.close();
+    }
+
+    /*
+     * Find EntityA_Embed_Coll_Embed
+     */
+    public void findEntityA_Embed_Coll_Embed() {
+        EntityManager em = emf.createEntityManager();
+        EntityA_Embed_Coll_Embed a = em.find(EntityA_Embed_Coll_Embed.class, ID);
+        checkEntityA_Embed_Coll_Embed(a);
+        em.close();
+    }
+
+    /*
+     * check EntityA_Coll_String
+     */
+    public void checkEntityA_Coll_String(EntityA_Coll_String a) {
+        int id = a.getId();
+        String name = a.getName();
+        int age = a.getAge();
+        assertEquals(1, id);
+        assertEquals("a" + id ,name);
+        assertEquals(1, age);
+        Set<String> nickNames = a.getNickNames();
+        for (String nickName : nickNames)
+            assertEquals("nickName_" + id + "0", nickName);
+    }
+
+    /*
+     * check EntityA_Embed_ToOne
+     */
+    public void checkEntityA_Embed_ToOne(EntityA_Embed_ToOne a) {
+        int id = a.getId();
+        String name = a.getName();
+        int age = a.getAge();
+        assertEquals(1, id);
+        assertEquals("a" + id ,name);
+        assertEquals(1, age);
+        Embed_ToOne embed = a.getEmbed();
+        checkEmbed_ToOne(embed);
+    }
+
+    /*
+     * check EntityA_Coll_Embed_ToOne
+     */
+    public void checkEntityA_Coll_Embed_ToOne(EntityA_Coll_Embed_ToOne a) {
+        int id = a.getId();
+        String name = a.getName();
+        int age = a.getAge();
+        assertEquals(1, id);
+        assertEquals("a" + id ,name);
+        assertEquals(1, age);
+        Set<Embed_ToOne> embeds = a.getEmbed1ToOnes();
+        for (Embed_ToOne embed : embeds)
+            checkEmbed_ToOne(embed);
+    }
+
+    public void checkEmbed_ToOne(Embed_ToOne embed) {
+        String name1 = embed.getName1();
+        String name2 = embed.getName2();
+        String name3 = embed.getName3();
+        assertEquals("name1", name1);
+        assertEquals("name2", name2);
+        assertEquals("name3", name3);
+        EntityB1 b = embed.getEntityB();
+        assertEquals(1, b.getId());
+        assertEquals("b" + b.getId(), b.getName());
+    }
+
+    /*
+     * check EntityA_Embed_ToMany
+     */
+    public void checkEntityA_Embed_ToMany(EntityA_Embed_ToMany a) {
+        int id = a.getId();
+        String name = a.getName();
+        int age = a.getAge();
+        assertEquals(1, id);
+        assertEquals("a" + id ,name);
+        assertEquals(1, age);
+        Embed_ToMany embed = a.getEmbed();
+        checkEmbed_ToMany(embed);
+    }
+
     public void checkEmbed_ToMany(Embed_ToMany embed) {
         String name1 = embed.getName1();
         String name2 = embed.getName2();
@@ -139,6 +592,172 @@
     }
     
     /*
+     * check EntityA_Embed_Coll_Integer
+     */
+    public void checkEntityA_Embed_Coll_Integer(EntityA_Embed_Coll_Integer a) {
+        int id = a.getId();
+        String name = a.getName();
+        int age = a.getAge();
+        assertEquals(1, id);
+        assertEquals("a" + id ,name);
+        assertEquals(1, age);
+        Embed_Coll_Integer embed = a.getEmbed();
+        checkEmbed_Integers(embed);
+    }
+
+    public void checkEmbed_Integers(Embed_Coll_Integer embed) {
+        int intVal1 = embed.getIntVal1();
+        int intVal2 = embed.getIntVal2();
+        int intVal3 = embed.getIntVal3();
+        assertEquals(11, intVal1);
+        assertEquals(12, intVal2);
+        assertEquals(13, intVal3);
+        Set<Integer> intVals = embed.getOtherIntVals();
+        for (Integer intVal : intVals) {
+            assertEquals(100, intVal.intValue());
+        }
+    }
+
+    /*
+     * check EntityA_Embed_Embed
+     */
+    public void checkEntityA_Embed_Embed(EntityA_Embed_Embed a) {
+        int id = a.getId();
+        String name = a.getName();
+        int age = a.getAge();
+        assertEquals(1, id);
+        assertEquals("a" + id ,name);
+        assertEquals(1, age);
+        Embed_Embed embed = a.getEmbed();
+        checkEmbed_Embed(embed);
+    }
+
+    public void checkEmbed_Embed(Embed_Embed embed) {
+        int intVal1 = embed.getIntVal1();
+        int intVal2 = embed.getIntVal2();
+        int intVal3 = embed.getIntVal3();
+        assertEquals(101, intVal1);
+        assertEquals(102, intVal2);
+        assertEquals(103, intVal3);
+        Embed embed1 = embed.getEmbed();
+        checkEmbed(embed1);
+    }
+
+    public void checkEmbed(Embed embed) {
+        int intVal1 = embed.getIntVal1();
+        int intVal2 = embed.getIntVal2();
+        int intVal3 = embed.getIntVal3();
+        assertEquals(104, intVal1);
+        assertEquals(105, intVal2);
+        assertEquals(106, intVal3);
+    }
+
+    /*
+     * check EntityA_Coll_Embed_Embed
+     */
+    public void checkEntityA_Coll_Embed_Embed(EntityA_Coll_Embed_Embed a) {
+        int id = a.getId();
+        String name = a.getName();
+        int age = a.getAge();
+        assertEquals(1, id);
+        assertEquals("a" + id ,name);
+        assertEquals(1, age);
+        List<Embed_Embed> embeds = a.getEmbeds();
+        for (Embed_Embed embed : embeds)
+            checkEmbed_Embed(embed);
+    }
+
+    /*
+     * check EntityA_Embed_Coll_Embed
+     */
+    public void checkEntityA_Embed_Coll_Embed(EntityA_Embed_Coll_Embed a) {
+        int id = a.getId();
+        String name = a.getName();
+        int age = a.getAge();
+        assertEquals(1, id);
+        assertEquals("a" + id ,name);
+        assertEquals(1, age);
+        Embed_Coll_Embed embed = a.getEmbed();
+        checkEmbed_Coll_Embed(embed);
+    }
+
+    public void checkEmbed_Coll_Embed(Embed_Coll_Embed embed) {
+        int intVal1 = embed.getIntVal1();
+        int intVal2 = embed.getIntVal2();
+        int intVal3 = embed.getIntVal3();
+        assertEquals(11, intVal1);
+        assertEquals(12, intVal2);
+        assertEquals(13, intVal3);
+        List<Embed> embeds = embed.getEmbeds();
+        for (Embed embed1 : embeds)
+            checkEmbed(embed1);
+    }
+
+    /*
+     * Query EntityA_Coll_String
+     */
+    public void queryEntityA_Coll_String() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        tran.begin();
+        Query q = em.createQuery("select a from EntityA_Coll_String a");
+        List<EntityA_Coll_String> as = q.getResultList();
+        for (EntityA_Coll_String a : as) {
+            checkEntityA_Coll_String(a);
+        }
+        tran.commit();
+        em.close();
+    }
+
+    /*
+     * Query EntityA_Embed_ToOne
+     */
+    public void queryEntityA_Embed_ToOne() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        tran.begin();
+        Query q = em.createQuery("select a from EntityA_Embed_ToOne a");
+        List<EntityA_Embed_ToOne> as = q.getResultList();
+        for (EntityA_Embed_ToOne a : as) {
+            checkEntityA_Embed_ToOne(a);
+        }
+        tran.commit();
+        em.close();
+    }
+
+    /*
+     * Query EntityA_Coll_Embed_ToOne
+     */
+    public void queryEntityA_Coll_Embed_ToOne() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        tran.begin();
+        Query q = em.createQuery("select a from EntityA_Coll_Embed_ToOne a");
+        List<EntityA_Coll_Embed_ToOne> as = q.getResultList();
+        for (EntityA_Coll_Embed_ToOne a : as) {
+            checkEntityA_Coll_Embed_ToOne(a);
+        }
+        tran.commit();
+        em.close();
+    }
+
+    /*
+     * Query EntityA_Embed_ToMany
+     */
+    public void queryEntityA_Embed_ToMany() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        tran.begin();
+        Query q = em.createQuery("select a from EntityA_Embed_ToMany a");
+        List<EntityA_Embed_ToMany> as = q.getResultList();
+        for (EntityA_Embed_ToMany a : as) {
+            checkEntityA_Embed_ToMany(a);
+        }
+        tran.commit();
+        em.close();
+    }
+
+    /*
      * Query EntityA_Embed_Embed_ToMany
      */
     public void queryEntityA_Embed_Embed_ToMany() {
@@ -154,5 +773,67 @@
         em.close();
     }
 
+    /*
+     * Query EntityA_Embed_Coll_Integer
+     */
+    public void queryEntityA_Embed_Coll_Integer() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        tran.begin();
+        Query q = em.createQuery("select a from EntityA_Embed_Coll_Integer a");
+        List<EntityA_Embed_Coll_Integer> as = q.getResultList();
+        for (EntityA_Embed_Coll_Integer a : as) {
+            checkEntityA_Embed_Coll_Integer(a);
+        }
+        tran.commit();
+        em.close();
+    }
 
+    /*
+     * Query EntityA_Embed_Embed
+     */
+    public void queryEntityA_Embed_Embed() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        tran.begin();
+        Query q = em.createQuery("select a from EntityA_Embed_Embed a");
+        List<EntityA_Embed_Embed> as = q.getResultList();
+        for (EntityA_Embed_Embed a : as) {
+            checkEntityA_Embed_Embed(a);
+        }
+        tran.commit();
+        em.close();
+    }
+
+    /*
+     * Query EntityA_Coll_Embed_Embed
+     */
+    public void queryEntityA_Coll_Embed_Embed() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        tran.begin();
+        Query q = em.createQuery("select a from EntityA_Coll_Embed_Embed a");
+        List<EntityA_Coll_Embed_Embed> as = q.getResultList();
+        for (EntityA_Coll_Embed_Embed a : as) {
+            checkEntityA_Coll_Embed_Embed(a);
+        }
+        tran.commit();
+        em.close();
+    }
+
+    /*
+     * Query EntityA_Embed_Coll_Embed
+     */
+    public void queryEntityA_Embed_Coll_Embed() {
+        EntityManager em = emf.createEntityManager();
+        EntityTransaction tran = em.getTransaction();
+        tran.begin();
+        Query q = em.createQuery("select a from EntityA_Embed_Coll_Embed a");
+        List<EntityA_Embed_Coll_Embed> as = q.getResultList();
+        for (EntityA_Embed_Coll_Embed a : as) {
+            checkEntityA_Embed_Coll_Embed(a);
+        }
+        tran.commit();
+        em.close();
+    }
 }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java?rev=724437&r1=724436&r2=724437&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java Mon Dec  8 10:27:45 2008
@@ -52,6 +52,7 @@
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import static javax.persistence.GenerationType.AUTO;
+import javax.persistence.ElementCollection;
 import javax.persistence.Id;
 import javax.persistence.IdClass;
 import javax.persistence.Lob;
@@ -1019,6 +1020,10 @@
                     parsePersistentCollection(fmd, (PersistentCollection)
                         el.getAnnotation(PersistentCollection.class));
                     break;
+                case ELEM_COLL:
+                    parseElementCollection(fmd, (ElementCollection)
+                        el.getAnnotation(ElementCollection.class));
+                    break;
                 case PERS_MAP:
                     parsePersistentMap(fmd, (PersistentMap)
                         el.getAnnotation(PersistentMap.class));
@@ -1471,6 +1476,27 @@
     }
 
     /**
+     * Parse @ElementCollection.
+     */
+    private void parseElementCollection(FieldMetaData fmd,
+        ElementCollection anno) {
+        if (fmd.getDeclaredTypeCode() != JavaTypes.COLLECTION &&
+            fmd.getDeclaredTypeCode() != JavaTypes.MAP)
+            throw new MetaDataException(_loc.get("bad-meta-anno", fmd,
+                "ElementCollection"));
+
+        if (anno.targetClass() != void.class)
+            fmd.getElement().setDeclaredType(anno.targetClass());
+        fmd.setInDefaultFetchGroup(anno.fetch() == FetchType.EAGER);
+        fmd.setElementCollection(true);
+        if (JavaTypes.maybePC(fmd.getElement())) {
+            fmd.getElement().setEmbedded(true);
+            if (fmd.getElement().getEmbeddedMetaData() == null)
+                fmd.getElement().addEmbeddedMetaData();
+        }
+    }
+    
+    /**
      * Parse @PersistentMap.
      */
     private void parsePersistentMap(FieldMetaData fmd, PersistentMap anno) {

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java?rev=724437&r1=724436&r2=724437&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java Mon Dec  8 10:27:45 2008
@@ -33,6 +33,7 @@
 import java.util.List;
 import java.util.ArrayList;
 import javax.persistence.Basic;
+import javax.persistence.ElementCollection;
 import javax.persistence.Embeddable;
 import javax.persistence.Embedded;
 import javax.persistence.EmbeddedId;
@@ -91,6 +92,7 @@
         _strats.put(ManyToMany.class, MANY_MANY);
         _strats.put(Persistent.class, PERS);
         _strats.put(PersistentCollection.class, PERS_COLL);
+        _strats.put(ElementCollection.class, ELEM_COLL);
         _strats.put(PersistentMap.class, PERS_MAP);
 
         _ignoredAnnos.add(DetachedState.class.getName());

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceStrategy.java?rev=724437&r1=724436&r2=724437&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceStrategy.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceStrategy.java Mon Dec  8 10:27:45 2008
@@ -41,5 +41,6 @@
     // openjpa extensions
     PERS,
     PERS_COLL,
+    ELEM_COLL,
     PERS_MAP,
 }



Mime
View raw message