cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Contextual callbacks
Date Thu, 11 Nov 2010 17:46:13 GMT
You may have noticed that I moved cayenne-mixins from github to Apache SVN. Now I am applying
the mixin design to a set of real-life problems, and it works pretty well in some scenarios
and less so in others (notably the issue with mixin property access code generation is in
the later category).

Now I am getting to the interesting area of working with implicit mixin relationships. E.g.
an audit object may have an (unmapped, implicit) relationship to a set of unrelated entities
based on UUID String stored in an audit object column. UUID looks like "Artist:3487" or "Join:1:2:3",
etc. This is essentially vertical inheritance, just without the mapping, and I want to keep
it that way instead of creating an open-ended number of subclasses. So meta-ORM...

Problem #1: fetching a list of N Audit objects, prefetching a list of N related auditable
objects from M (M <= N) tables. I am solving that with a generic property in Audit and
a POST_LOAD callback reading Auditable. I don't want to execute N Auditable queries, instead
I would like to prefetch them in batches. To do that, POST_LOAD would record UUID of Audit
object, and then when all POST_LOAD's are called, I'd run M prefetch queries organized by
Auditable type. But since callbacks are invoked outside a transaction, we don't have a context
to gather UUIDs, and don't know when the query ended.

So a few solutions that I see here:

* extend the scope of the Transaction object, and add post-callbacks hook to it. Also add
a property map to transaction that would allow user apps to attach arbitrary stuff to it.
I wanted to do it some time back. Now is a good occasion.

* create a special callbacks context spanning either POST_<commit> or POST_LOAD, so
it would allow to look at all objects processed in a given transaction. It will have its own
callback events.

There are probably other solutions as well. Just thinking out loud...

Andrus

 



Mime
View raw message