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);