cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Reich <markus.re...@markusreich.at>
Subject CommitChangesToParent() <> CommitChanges()
Date Thu, 23 Feb 2017 07:26:55 GMT
Hi,

I'm having some troubles understanding commitChanges() and
commitChangesToParent() :-/

I've created a test case with two ObjectContexts
ObjectContext context1 = runtime.newContext();
ObjectContext context2 = runtime.newContext();

then I load the same entity in both contexts
PpAfkoPordershead order1 = PpAfkoPordershead.getByAufnr(context1, 123);
PpAfkoPordershead order2 = PpAfkoPordershead.getByAufnr(context2, 123);

then I tried this
Integer quantity = order1.getQuantity();
order1.setQuantity(quantity + 1);
context1.commitChanges();
Assert.assertEquals(quantity, order2.getQuantity());

this works as the second context get synched by the commit.

but why does this work too?
Integer quantity = order1.getQuantity();
order1.setQuantity(quantity + 1);
context1.commitChangesToParent();
Assert.assertEquals(quantity, order2.getQuantity());

regards
Meex

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message