From d23199bf20cdc471a4f589ac23d1f12e3b69ecd6 Mon Sep 17 00:00:00 2001 From: Pinaki Poddar Date: Thu, 21 Jan 2010 00:31:06 +0000 Subject: [PATCH] OPENJPA-1474: Setting intermediate field should take into account the loaded state git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@901464 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/jdbc/kernel/JDBCStoreManager.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 e7d7bd87b..451edbf53 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 @@ -369,8 +369,7 @@ public class JDBCStoreManager Object mappedByObject = info.result.getMappedByValue(); if (mappedByFieldMapping != null && mappedByObject != null) if (mappedByObject instanceof OpenJPAId && - mapping.getExtraFieldDataIndex(mappedByFieldMapping. - getIndex()) != -1) + mapping.getExtraFieldDataIndex(mappedByFieldMapping.getIndex()) != -1) { // The inverse relation can not be set since // we are eagerly loading this sm for // a sm owner that is still in the process of @@ -379,10 +378,15 @@ public class JDBCStoreManager // The inverse relation is set later by // setInverseRelation() when the sm owner is fully // initialized. - sm.setIntermediate(mappedByFieldMapping.getIndex(), - mappedByObject); - else + int index = mappedByFieldMapping.getIndex(); + if (sm.getLoaded().get(index)) { + sm.setImplData(index, mappedByObject); + } else { + sm.setIntermediate(index, mappedByObject); + } + } else { setMappedBy(sm, mappedByFieldMapping, mappedByObject); + } } // load the selected mappings into the given state manager if (res != null) {