openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From allee8...@apache.org
Subject svn commit: r1134062 - /openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
Date Thu, 09 Jun 2011 20:07:37 GMT
Author: allee8285
Date: Thu Jun  9 20:07:36 2011
New Revision: 1134062

URL: http://svn.apache.org/viewvc?rev=1134062&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=1134062&r1=1134061&r2=1134062&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
Thu Jun  9 20:07:36 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