From 80aea14f18227ceafca32cc4a36f614280a7fcc9 Mon Sep 17 00:00:00 2001 From: Catalina Wei Date: Sun, 8 Feb 2009 01:43:45 +0000 Subject: [PATCH] OPENJPA-912 Potential NPE in setInverseRelation git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@741994 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java | 4 ++++ .../openjpa/persistence/relations/TestChainEntities.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java index b7b98687e..cb853d426 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java @@ -392,6 +392,10 @@ public class JDBCStoreManager for (Iterator itr = ((Collection) coll).iterator(); itr.hasNext();) { PersistenceCapable pc = (PersistenceCapable) itr.next(); + + if (pc == null) + continue; + OpenJPAStateManager sm = (OpenJPAStateManager) pc. pcGetStateManager(); FieldMapping[] fmd = ((ClassMapping) sm.getMetaData()). diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestChainEntities.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestChainEntities.java index c0c457d4d..2b32fff48 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestChainEntities.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestChainEntities.java @@ -32,7 +32,8 @@ public class TestChainEntities extends SingleEMFTestCase { long aid; public void setUp () { - setUp (ChainEntityA.class, ChainEntityB.class, ChainEntityC.class); + setUp (DROP_TABLES, + ChainEntityA.class, ChainEntityB.class, ChainEntityC.class); // Create A ChainEntityA a = new ChainEntityA (); a.setName ("TEST_A");