In my application I have something like this:
ImageSpecification[id, width, height]
ImageSpecification.getCanonicalInstance() issues a query and if a given
[width, height] combination already exists in the database, returns an
instance of that object. So for example, if specification1 and
specification2 both have the same [width, height], specification1 is
already in the database and I invoke
specification2.getCanonicalInstance() then I'd expect it to return
specification1.
Now ... here is where the problems begin. Currently, Cayenne treats a
DataContext as a scratch-pad (to borrow Mike's terminology), not a
transaction. If I execute the following code:
context.deleteObject(specification1);
specification2 = specification2.getCanonicalInstance();
then specification2 will end up equal to specification1. Why? Because
as far as Cayenne is concerned, specification1 has not yet been removed
from the DB (we haven't yet invoked commitChanges()) and so it is a
valid result.
I'm expecting Cayenne to be a bit smarter with queries and treat the
DataContext as a transaction, not just a scratch-pad. This means that
when specification2.getCanonicalInstance() is invoked, Cayenne should be
smart enough to realize that from the point of view of the current
context "specification1" has been deleted, and so it should not show up
in the query results. Implementing this change should be easy enough (I
can contribute the patch).
Is it possible/reasonable to modify Cayenne to act this way? From my
point of view, it's an ease-of-use issue. The user can explicitly check
deletedObjects() but he shouldn't have to (is there a benefit to having
to check explicitly?) What do you think?
Thanks,
Gili
-- http://www.desktopbeautifier.com/
This archive was generated by hypermail 2.0.0 : Thu Sep 08 2005 - 03:12:06 EDT