On Mar 29, 2008, at 8:39 PM, Kevin Menard wrote:

I think we may have had a different understanding of what redundant means. I was thinking internal to Cayenne, not considering relationships mapped by
the user as "redundant", even if they may in fact be.

There's no difference in the runtime... Redundant is redundant, and we either know how to handle it or not.

A lazy person in me votes for the later option. Or maybe not that
lazy? I always liked my object graph structure to avoid any
inconsistency (e.g. assume relationship cardinality that DB does not
enforce) and redundancy (e.g. RelatedEntity double relationships over
the same set of joins). So mentally I never allowed myself to map
anything like that, and never felt the need to do so. So maybe we
shouldn't enable this scenario, complicating the framework
significantly, just because we can?

Yeap, this is the core of what I was getting at. One problem I see is that the autocreated runtime relationships affects the relationship cardinality and can be a real pain in the neck for the user to debug. Any error message would not match what the user has mapped and their non-intuitive naming would not lend to easy debugging. Please note I'm talking about runtime relationships created for base classes, as demonstrated in the test for
CAY-1009.

Hmm... Bailing on runtime relationships (at least on the required variety) would result in us losing support for one-way to-many (and IIRC also one-way 1..1) which would be a very serious downgrade. I don't see any *simple* alternative to handle that functionality. But i we develop one, I'd say drop runtime ObjRelationships and only keep the Db.

Until then that I'd rather change my earlier statement about "BaseEntity -> DirectToSubEntity -> SubEntity" relationships chain, and call it "implicitly redundant". This would be equivalent to the following rule:

"All Cayenne ObjRelationships implicitly or explicitly require a single reverse relationship. If the mapping does not contain a reverse relationship, Cayenne creates one (invisible to the user) during runtime. If the mapping results in more than one relationship matching reverse relationship criteria, this will result in a runtime exception thrown".

That's how I see the "lazy" option implementation.

Andrus

Reply via email to