George-
I'm not sure the exact problem (your model looks OK to me at first
glance), but FTR, I just tried a simple test with a query that
returns "ob, ob.someOneToOne", and it returned the expected values
(in this case, a
org.apache.openjpa.persistence.models.company.basic.Customer and
org.apache.openjpa.persistence.models.company.basic.Address
instance). So projecting over relations isn't fundamentally broken,
although there may very well be a bug in there somewhere.
Can you try to refine down your test case so it is just two simple
entities and a test case that exhibits the bug? That will make it
easier to isolate the cause. Opening a JIRA issue while you are at it
would be useful :)
On Apr 5, 2007, at 6:05 PM, George Hongell wrote:
Query returning 2 entities w/1-1 relationship gets either
openjpa.persistence.ArgumentException : Address with the same id
already exists in the L1 cache. or returns [Address, Address]
instead of [Winery, Address]
depending on select order
if
_em.find(Winery.class,parm1) is not executed before
query.getResultList().
"SELECT r,r.address" returns [Address, Address] and "SELECT
r.address,r" gets same Address id already exists in the L1 cache
Run main program in BugWineryTest class in attached application to
reproduce Error.
----------------------------------------------------------------------
-------
701 bugwineTour TRACE [main] openjpa.jdbc.SQL - <t 1094861122, conn
1652187770> [0 ms] spent
1171 bugwineTour TRACE [main] openjpa.jdbc.SQL - <t 1094861122,
conn 1652187770> executing prepstmnt 887502054 SELECT t1.phone,
t1.version, t1.city, t1.state, t1.street, t1.zip, t0.wineryid FROM
bugWinery t0 LEFT OUTER JOIN bugAddress t1 ON t0.address_phone =
t1.phone WHERE (t0.wineryid = ?) [params=(int) 1]
1171 bugwineTour TRACE [main] openjpa.jdbc.SQL - <t 1094861122,
conn 1652187770> [0 ms] spent
<4|false|0.9.7-incubating-SNAPSHOT>
org.apache.openjpa.persistence.ArgumentException: Cannot load
object with id "1". Instance "
com.ibm.websphere.ejb3sample.winetour.bug.Address-1" with the same
id already exists in the L1 cache. This can occur when you assign
an existing id to a new instance, and before flushing attempt to
load the existing instance for that id.
FailedObject: com.ibm.websphere.ejb3sample.winetour.bug.Address-1
at org.apache.openjpa.kernel.BrokerImpl$ManagedCache.add(
BrokerImpl.java:4418)
at org.apache.openjpa.kernel.BrokerImpl.setStateManager(
BrokerImpl.java:3773)
at org.apache.openjpa.kernel.StateManagerImpl.initialize(
StateManagerImpl.java:297)
at org.apache.openjpa.kernel.StateManagerImpl.initialize(
StateManagerImpl.java:258)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(
JDBCStoreManager.java:327 )
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(
JDBCStoreManager.java:252)
at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(
DelegatingStoreManager.java:108 )
at org.apache.openjpa.kernel.ROPStoreManager.initialize(
ROPStoreManager.java:54)
at org.apache.openjpa.kernel.BrokerImpl.initialize(
BrokerImpl.java:873)
at org.apache.openjpa.kernel.BrokerImpl.find(
BrokerImpl.java:831)
at org.apache.openjpa.kernel.BrokerImpl.find(
BrokerImpl.java:753)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(
JDBCStoreManager.java:773)
at org.apache.openjpa.jdbc.sql.AbstractResult.load(
AbstractResult.java:254)
at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(
SelectImpl.java:2115)
at org.apache.openjpa.jdbc.kernel.exps.PCPath.load(
PCPath.java:684)
at org.apache.openjpa.jdbc.kernel.exps.PCPath.load(
PCPath.java:672)
at
org.apache.openjpa.jdbc.kernel.ProjectionResultObjectProvider.getResul
tObject(
ProjectionResultObjectProvider.java:73 )
at org.apache.openjpa.lib.rop.EagerResultList.<init>(
EagerResultList.java:33)
at org.apache.openjpa.kernel.QueryImpl.toResult(
QueryImpl.java:1214)
at org.apache.openjpa.kernel.QueryImpl.execute(
QueryImpl.java:981)
at org.apache.openjpa.kernel.QueryImpl.execute(
QueryImpl.java:834)
at org.apache.openjpa.kernel.QueryImpl.execute(
QueryImpl.java:765)
at org.apache.openjpa.kernel.DelegatingQuery.execute(
DelegatingQuery.java:520)
at org.apache.openjpa.persistence.QueryImpl.execute(
QueryImpl.java:224)
at org.apache.openjpa.persistence.QueryImpl.getResultList(
QueryImpl.java:264)
at
com.ibm.websphere.ejb3sample.winetour.bug.BugWineryTest.test_1_1relati
onshipQuery_Winery_address(
BugWineryTest.java:434 )
at com.ibm.websphere.ejb3sample.winetour.bug.BugWineryTest.main(
BugWineryTest.java:90)
<1_1BugWineryTest.zip>