Umm... direction of DbRelationships (and resulting requirement to have
them duplicated two ways) is something I really don't like and want to
get rid of. It simply seems redundant, though many things in Cayenne
depend on it, so it won't be easy.
Back to your question... "Is it OK to model multiple relationships to
the same table?" - Yes, but you have to assign unique names to
relationships on each side. It makes sense to do so, as different
relationships use different joins and are therefore distinct from each
other.
If on the object side you have a rule that only one "transaction" can
exist for a given term (either preliminary or final, but not both), you
can create your own "getTransaction()" method that does something like
"return (getPreliminary() != null) ? getPreliminary() : getFinal()".
This should not lead to any inefficiency, as NULL FK will immediately
tell Cayenne that there is nothing to fetch on the other side.
Andrus
On Oct 5, 2004, at 12:57 PM, Gentry, Michael wrote:
> I have a Transaction table which has a to-one relationship
> (preliminarySubmissionTerms) to a TransactionTerms table. It also has
> a
> to-one relationship (finalSubmissionTerms) to the TransactionTerms
> table.
>
> I get an error in the modeler because I can't add the return
> relationship (transaction) in the second relationship because the name
> conflicts (for obvious reasons). If I leave it empty in the second
> relationship I get a warning saying "DbRelationship has no joins."
>
> I could call the return relationships different names, but if I'm ever
> at a TransactionTerm, I'd hate to have to know if I was preliminary or
> final to call the "correct" method to get the Transaction.
>
> If that was confusing ...
>
> Transaction
> <-> TransactionTerms (preliminarySubmissionTerms)
> <-> TransactionTerms (finalSubmissionTerms)
>
> Thanks,
>
> /dev/mrg
>
> PS. I know the return relationship is modeled as a to-many, but it's
> only ever used as a to-one in this case.
>
This archive was generated by hypermail 2.0.0 : Tue Oct 05 2004 - 22:12:13 EDT