From f1ac625b2c931ee1cb99e4eb98fdcbd8d523b781 Mon Sep 17 00:00:00 2001 From: Pinaki Poddar Date: Wed, 11 Jun 2008 03:33:35 +0000 Subject: [PATCH] OPENJPA-209: Detect identical instances being added to L1 cache multiple times during a load session. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@666515 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/jdbc/kernel/ProjectionResultObjectProvider.java | 2 ++ .../main/java/org/apache/openjpa/kernel/StateManagerImpl.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ProjectionResultObjectProvider.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ProjectionResultObjectProvider.java index b28ee7eb6..56e04ebdd 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ProjectionResultObjectProvider.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ProjectionResultObjectProvider.java @@ -70,6 +70,8 @@ class ProjectionResultObjectProvider public Object getResultObject() throws Exception { Result res = getResult(); + // for a projection, Result has no base mapping + res.setBaseMapping(null); int idx = res.indexOf(); Object[] arr = new Object[_exps[idx].projections.length]; for (int i = 0; i < _exps[idx].projections.length; i++) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java index 5d863b858..b2949deb0 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java @@ -311,7 +311,9 @@ public class StateManagerImpl // initialize our state and add ourselves to the broker's cache setPCState(state); - _broker.setStateManager(_id, this, BrokerImpl.STATUS_INIT); + if (_broker.getStateManagerImplById(getObjectId(), false) == null) { + _broker.setStateManager(_id, this, BrokerImpl.STATUS_INIT); + } if (state == PCState.PNEW) fireLifecycleEvent(LifecycleEvent.AFTER_PERSIST);