You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Øyvind Harboe <oy...@zylin.com> on 2006/12/18 22:27:49 UTC

Problems with DataContext being null in object

Under which circumstances can a Cayenne Data Object have it's Data
Context set to null?

I see 5 (five!) cases:

- application invokes setDataContext(null)
- Cayenne rolls back a new uncommitted object.
- committed deleted object
- serialize + deserialize
- explicit invalidation/unregistering of objects

a) is this list complete? I'm using Cayenne 1.2

b) This makes me wonder whether the following construct is safe in
*all* cases. Especially I'm a bit concerned about what happens when
this is executed on a DataContext:


try
{
  context.commitChanges();
}
{
// roll back after a successful commit is *supposed* to be a no-op, so we
// execute this always for simplicity
//
// or is it?????
context.rollbackChanges();
}



(The persistance="yes" thingy I wrote today is a real concern for our
app, but not the culprit for my particular problems right now.)

-- 
Øyvind Harboe
http://www.zylin.com