That's affirmative. At present we do not handle circular relationships in a
constraint-proof manner. If they are really necessary for the database
schema in question one can always fall back on the *deferred* constraints if
the database supports them. The schemas containing no referential
circularities (cycles) are handled by Cayenne. The corresponding algorithms
and the relevant Cayenne code underwent highly intensive testing, so as for
now I feel quite sure about them. The reflexive or self-referencing tables
are the only case when we resolve circular referential dependencies working
on the level of data rows instead of entities. This part was thoroughtly
tested as well. The only natural limitation with the algorithm I am aware of
is a possible problem with the resolution of cycles among the modified data
rows in such a table. This may happen when one tries to make a data row a
descendant of itself. The case when a data row is a child of itself is
handled properly though, since rdmbs normally allow to insert a row
referencing itself. If one really needs to deal with more general cycles in
a hierarchical table the *deferred* option should be tried, I think.
Thanks.
Andriy.
----- Original Message -----
From: "Andrus Adamchik" <andru..bjectstyle.org>
To: <cayenne-use..bjectstyle.org>
Sent: Friday, January 30, 2004 3:11 AM
Subject: Re: New objects break FK constraints
>
> On Jan 29, 2004, at 11:41 AM, Jim Menard wrote:
>
> > Andrus,
> >
> >> Ordering of operations has been around for a while and proved to be
> >> very stable. I am fairly sure there is something with the mapping of
> >> the relationship (DB constraints and Cayenne mapping do not match).
> >> Is this the case described here:
> >> http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-41
> >
> > No, it's different. The Member table has a FK to BillAccount, but the
> > BillAccount does not directly refer to the member at all.
> >
> > There is one more class in the mix: Address. Each address has a
> > nullable FK back to the member. Maybe that's causing the problem? I
> > need to write a simple test case to see what's going on.
>
> Now that I have a DataMap to look at, I se what is happening. Entities
> have a circular dependency: Address depends on Member, Member depends
> on BillAccount, BillAccount depends on Address:
>
> Address -> Member -> BillAccount -> Address
>
> So ordering can't be resolved just by analyzing entity dependencies. Of
> course it can be resolved at the row level - if Address belongs to
> BillAccount, it should be inserted first, if it belongs to a Member -
> it should be inserted last.
>
> Cayenne doesn't handle such relationship cycles yet. On the other hand
> the case that Arndt mentioned - entities with simple reflexive
> relationships - seems to be handled in the code. Andriy may know better
> if it has any more limitations, since he wrote it, but from what I see
> parent-child relationships in the same table should be sorted properly.
>
> But regardless of this limitation, I think the schema can be redesigned
> to remove the cycle. member.bill_account_id can be substituted with
> bill_account.member_id. If I understand it correctly, a bill_account
> always belongs to a single member, right? It is not shared by multiple
> people?
>
> Andrus
>
>
This archive was generated by hypermail 2.0.0 : Fri Jan 30 2004 - 01:15:19 EST