Hi Marcin,
I just tried to reproduce it with the code from HEAD, and it seems to
work
(CayenneContextClientChannelEventsTst.testSyncManyToManyRelationship1).
Don't know if you have an opportunity to upgrade from 3.0-PROTO to
HEAD (this will require package changes to Apache, and also using the
new Modeler from HEAD). If not, please either submit your test case
via Jira or send it to me directly. Let's take a look.
Andrus
On Aug 6, 2006, at 3:35 AM, Marcin Skladaniec wrote:
> Hi everyone !
>
> I have a problem with some counts in flattened many to many
> relationships. (remote persistence, v.3.0-PROTO July 5 2006)
> Generally the problem is when object exist in two contexts and the
> many to many relationship is modified.
> To reproduce this :
>
> CayenneContext context = new CayenneContext(channel, true, true);
>
> CLocation location = (CLocation) context.newObject
> (CLocation.class);
> CSpiece spiece = (CSpiece) context.newObject(CSpiece.class);
> context.commitChanges();
> logger.warn("location has spieces : "+location.getSpieces
> ().size()); //prints 0 as supposed.
>
> CayenneContext context2 = new CayenneContext(channel, true,
> true);
>
> CLocation loc = (CLocation)context2.localObject
> (location.getObjectId(), null);
> CSpiece sp = (CSpiece)context2.localObject(spiece.getObjectId(),
> null);
>
> loc.addToSpieces(sp);
> context2.commitChanges();
> logger.warn("loc has spieces : "+loc.getSpieces().size
> ()); // prints 1 as expected
>
> logger.warn("location has spieces : "+location.getSpieces
> ().size());// prints 2, and here lies the problem.
>
> printing all spieces for location gives two results :
> 1 - <cayenne3t.example.hr.CSpiec..740418,
> id=<ObjectId:Spieceid=280>, state=committed,
> context=org.objectstyle.cayenne.CayenneContex..5e2cf>
> 2 - <cayenne3t.example.hr.CSpiec..740418,
> id=<ObjectId:Spieceid=280>, state=committed,
> context=org.objectstyle.cayenne.CayenneContex..5e2cf>
> Of course in context this object exists only once.
>
> If new context is spawned everything works fine, but I cant use new
> context in this case.
> There is no problem as well when removing from relationship.
>
> Is it a bug, or I'm doing something wrong here ?
>
> Marcin
> PS I have a small standalone project which reproduces this problem,
> if it would be needed please e-mail me.
>
> -------------------------->
> ish
> http://www.ish.com.au
> Level 1, 30 Wilson Street Newtown 2042 Australia
> phone +61 2 9550 5001 fax +61 2 9550 4001
This archive was generated by hypermail 2.0.0 : Sun Aug 06 2006 - 21:15:18 EDT