openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r1152904 - /openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
Date Mon, 01 Aug 2011 19:23:33 GMT
Author: mikedd
Date: Mon Aug  1 19:23:33 2011
New Revision: 1152904

URL: http://svn.apache.org/viewvc?rev=1152904&view=rev
Log:
OPENJPA-2015 Add to relationship collection only if type matches.

Modified:
    openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java

Modified: openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java?rev=1152904&r1=1152903&r2=1152904&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
(original)
+++ openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
Mon Aug  1 19:23:33 2011
@@ -123,7 +123,11 @@ public abstract class StoreCollectionFie
      * By default, assumes the structure is a collection.
      */
     protected void add(JDBCStore store, Object coll, Object obj) {
-        ((Collection) coll).add(obj);
+       	Class<?> elemClazz = field.getElement().getDeclaredType();
+       	if( elemClazz == null || obj == null || 
+            elemClazz.isAssignableFrom(obj.getClass())) {
+            ((Collection) coll).add(obj);
+       	}
     }
 
     /**



Mime
View raw message