Hi Peter, Not sure if this has been mentioned in this thread already, but once you identify the entities with messed up order, you can use @SortWeight annotation and WeightedAshwoodEntitySorter. E.g.:
https://lists.apache.org/thread.html/0452cd5ca9de85f19882539710588f1b221da7627f845902ed10a7b6@1461051077@%3Cuser.cayenne.apache.org%3E This is not a universal solution, but may help with a number of Ashwood sorter shortcomings. Andrus > On Dec 8, 2016, at 9:20 PM, Michael Gentry <[email protected]> wrote: > > PS. I wasn't intending to be confusing with the recursive relationship > comment. I just wanted to illustrate that as far as Cayenne/Ashwood are > concerned, there is a difference between A->B->A and A->A. The first is > circular, the second is recursive. To quote the AshwoodEntitySorter > documentation: "Presently it works for acyclic [what I called circular, or > non-circular in this instance] database schemas with possible > multi-reflexive [what I called recursive] tables." > > > On Thu, Dec 8, 2016 at 11:30 AM, Michael Gentry <[email protected]> > wrote: > >> Hi Peter, >> >> I don't think that's a circular graph, unless perhaps you have more >> relationships that are omitted. You have: >> >> Person->Country >> Person->Telephone->Country >> >> Neither of those circle back to Person. Note: It's fine to have >> Person->Person. Cayenne supports recursive relationships. >> >> mrg >> >> >> >> On Thu, Dec 8, 2016 at 10:14 AM, fael <[email protected]> wrote: >> >>> Hi Michael, >>> >>> Thanks for your reply here! >>> >>> I did indeed come across the discussions on the Ashwood sorter and >>> circular >>> dependencies. When you speak of a circular object graph and taking your A >>> -> >>> B ... -> A example I just wanted to clarify and confirm that your example >>> is >>> essentially as follows; >>> >>> Imagine these are the tables; >>> A[id (primary key), b_id] >>> B[id (primary key), c_id] >>> C[id (primary key), d_id] >>> D[id (primary key), e_id] >>> E[id (primary key), a_id] >>> >>> And these the foreign keys; >>> A.b_id - B.id >>> B.c_id - C.id >>> C.d_id - D.id >>> D.e_id - E.id >>> E.a_id - A.id >>> >>> -------------- >>> >>> The sort of cycle I might have is as follows; >>> >>> Person[id (pk), country_id, telephone_id] >>> Telephone[id (pk), country_id, number] >>> Country[id (pk)] >>> >>> Person.country_id = Country.id >>> Person.telephone_id = Telephone.id >>> Telephone.country_id = Country.id >>> >>> Do you think this counts as the sort of cycle that might cause this sort >>> of >>> dice rolling effect? >>> >>> Thanks again! >>> Peter >>> >>> >>> >>> >>> >>> -- >>> View this message in context: http://cayenne.195.n3.nabble.c >>> om/Erratic-AshwoodEntitySorter-NPE-on-Latest-Snapshot-tp4027 >>> 453p4028309.html >>> Sent from the Cayenne - User mailing list archive at Nabble.com. >>> >> >>
