I've been thinking a lot about how to implement vertical inheritance using
Cayenne.
These are the changes I see as necessary:
1) Specify a superEntity and the relationship pointing to that entity.
For example, if I have Group and Organization, with Organization inheriting
from Group, and having a dependent PK on Group, and a to-one relationship to
group named "toGroup", then I need to both mark Group as the superEntity and
mark "toGroup" as the superEntity relationship. I think this is the only
change needed in the model and modeler.
2) Create templates to support vertical inheritance.
These would basically delegate any read/writes to the superEntity for all
superEntity attributes and relationships. Possibly also create a
constructor creating the superentity and setting the relationship.
3) Change DataContext to modify superEntity status (recursively) when entity
is registered/invalidated. Primarily, I see this as necessary for
registering and invalidating a new entity. The templates can actually
provide support for creation (call superEntity constructor in the
constructor and set the relationship), and the delete rules can handle the
case of deletion. Modification is already taken care of by the template
delegation. There may be other DataContext changes necessary -- I haven't
really looked over DC in detail to see if there's anything else i missed.
==
Actually, I've went back and re-read Michael's original message on using
setPersistenceState() to handle NEW (and could, by extension, handle HOLLOW)
for registration/invalidation. So perhaps this could also be
template-generated and handled in the DataObject as well.
Also, since Vertical Inheritance relies on a dependant PK to the
superEntity, perhaps that also doesn't need to be modeled. It'd be the only
dependant-PK to-one relationship.
So maybe it should all be handled by templating. The only "trick" would be
getting a reference to the superEntity in the template, but that should be
possible.
Thoughts?
As a first-attempt, this seems like the path of least resistance (and
least-likely to break something). Being able to "see" vertical inheritance
in the modeler (a la EOModeler) would be nice, but isn't a necessity.
-Mike
This archive was generated by hypermail 2.0.0 : Fri May 20 2005 - 11:50:24 EDT