cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrey Razumovsky (JIRA)" <j...@apache.org>
Subject [jira] Closed: (CAY-1195) cannot access a many to many relationship before commit
Date Tue, 17 Mar 2009 20:38:17 GMT

     [ https://issues.apache.org/cayenne/browse/CAY-1195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Andrey Razumovsky closed CAY-1195.
----------------------------------

    Resolution: Won't Fix

Sorry, there's no fix avaliable. This one can also be reproduced with normal contexts, and
much easier:

ClientMtTable4 parentMt = context.newObject(ClientMtTable4.class);
ClientMtTable4 parentMtCopy = (ClientMtTable4) context2.localObject(parentMt.getObjectId(),
null);
parentMtCopy.getTable5s();

"parentMtCopy" object, which is created using localObject(..., *null*) is HOLLOW. As you didn't
specify any info in second parameter, there's no way to resolve the object! And parentMt is
not commited, so fetch from DB also fails.

I first thought we could forbid creating localObject(...) copy from NEW object. But this is
also not good, because I could write something like this:

ClientMtTable4 parentMt = context.newObject(ClientMtTable4.class);
ClientMtTable4 parentMtCopy = (ClientMtTable4) context2.localObject(parentMt.getObjectId(),
null);
context.commitChanges();
parentMtCopy.getTable5s();

And it would work!

> cannot access a many to many relationship before commit
> -------------------------------------------------------
>
>                 Key: CAY-1195
>                 URL: https://issues.apache.org/cayenne/browse/CAY-1195
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Cayenne Core Library
>    Affects Versions: 3.0M6
>         Environment: ROP
>            Reporter: Marcin Skladaniec
>            Assignee: Andrey Razumovsky
>
> the many to many relationship cannot be accessed from the other side that it was set.
> test case (sorry not as a patch, to much other modifications to be able to create a diff)
>  public void testCAY1195() throws Exception {
>         deleteTestData();
>         
>         ClientMtTable4 parentMt = context.newObject(ClientMtTable4.class);
>         ClientMtTable5 childMt5 = context2.newObject(ClientMtTable5.class); // I added
context2 to the RemoteCayenneCase. it is created the same way as the original context
>         
>         assertEquals(0,parentMt.getTable5s().size());
>         assertEquals(0,childMt5.getTable4s().size());
>         
>         ClientMtTable4 parentMtCopy = (ClientMtTable4)context2.localObject(parentMt.getObjectId(),
null);
>         childMt5.addToTable4s(parentMtCopy);
>         
>         assertEquals(1,parentMtCopy.getTable5s().size());
>         assertEquals(1,childMt5.getTable4s().size());
>     }
> this test throws a following exception:
> Tests run: 17, Failures: 1, Errors: 1, Skipped: 0, Time elapsed: 0.415 sec <<<
FAILURE!
> testCAY1195(org.apache.cayenne.remote.NestedObjectContextTest)  Time elapsed: 0.016 sec
 <<< ERROR!
> org.apache.cayenne.CayenneRuntimeException: [v.3.0-SNAPSHOT ${project.build.date} ${project.build.time}]
Can't build a query for temporary id: <ObjectId:MtTable4, TEMP:0191B517AE610004>
> 	at org.apache.cayenne.query.ObjectIdQuery.createReplacementQuery(ObjectIdQuery.java:124)
> 	at org.apache.cayenne.query.IndirectQuery.getReplacementQuery(IndirectQuery.java:74)
> 	at org.apache.cayenne.query.IndirectQuery.route(IndirectQuery.java:57)
> 	at org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:414)
> 	at org.apache.cayenne.access.DataDomainQueryAction.access$0(DataDomainQueryAction.java:401)
> 	at org.apache.cayenne.access.DataDomainQueryAction$2.transform(DataDomainQueryAction.java:395)
> 	at org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:846)
> 	at org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:392)
> 	at org.apache.cayenne.access.UnitTestDomainQueryAction.runQueryInTransaction(UnitTestDomainQueryAction.java:54)
> 	at org.apache.cayenne.access.DataDomainQueryAction.interceptOIDQuery(DataDomainQueryAction.java:156)
> 	at org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:113)
> 	at org.apache.cayenne.access.UnitTestDomainQueryAction.execute(UnitTestDomainQueryAction.java:48)
> 	at org.apache.cayenne.access.UnitTestDomain.onQuery(UnitTestDomain.java:63)
> 	at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:333)
> 	at org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:96)
> 	at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1268)
> 	at org.apache.cayenne.access.ClientServerChannelQueryAction.runQuery(ClientServerChannelQueryAction.java:119)
> 	at org.apache.cayenne.access.ClientServerChannelQueryAction.execute(ClientServerChannelQueryAction.java:65)
> 	at org.apache.cayenne.access.ClientServerChannel.onQuery(ClientServerChannel.java:81)
> 	at org.apache.cayenne.remote.service.DispatchHelper.dispatch(DispatchHelper.java:39)
> 	at org.apache.cayenne.remote.service.LocalConnection.doSendMessage(LocalConnection.java:125)
> 	at org.apache.cayenne.remote.BaseConnection.sendMessage(BaseConnection.java:72)
> 	at org.apache.cayenne.unit.UnitLocalConnection.sendMessage(UnitLocalConnection.java:49)
> 	at org.apache.cayenne.remote.ClientChannel.send(ClientChannel.java:280)
> 	at org.apache.cayenne.remote.ClientChannel.onQuery(ClientChannel.java:112)
> 	at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:333)
> 	at org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:96)
> 	at org.apache.cayenne.CayenneContext.onQuery(CayenneContext.java:348)
> 	at org.apache.cayenne.CayenneContext.performQuery(CayenneContext.java:338)
> 	at org.apache.cayenne.BaseContext.prepareForAccess(BaseContext.java:144)
> 	at org.apache.cayenne.testdo.mt.auto._ClientMtTable4.getTable5s(_ClientMtTable4.java:21)
> 	at org.apache.cayenne.remote.NestedObjectContextTest.testCAY1(NestedObjectContextTest.java:642)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message