Re: Marking an ObjectContext as "done, don't use"
Andrus Adamchik <[email protected]>
| Newsgroups | gmane.comp.java.cayenne.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Hugi, There's only so many options considering that the framework does not provide any explicit API for this. Yours is as good as any. Curios about a specific scenario why you need it. Andrus > On Oct 15, 2019, at 6:26 AM, Hugi Thordarson <[email protected]> wrote: > > Hi all, > i'm looking for suggestions on an approach to mark an ObjectContext as "obsolete", i.e. to explicitly state that I'm now done with it and any further operations on it (preferably even any objects in it) signify a logical error/bad state. > > First thought is to create my own DataContext subclass with a simple boolean marker, and override methods like commitChanges() and onQuery() to throw an exception if the marker is set. At least that provides partial safety. But I'm wondering if anyone has suggestions for a better approach? > > Cheers, > - hugi