Hi Bruno,

The entity sorting in Cayenne is currently handled by the Ashwood
Entity Sorter.  For the most part this works fine, but in some
situations (long graph cycles), it does not compute the correct
insertion order or fails to throw an exception to make it easier to
debug the problem.  I had started writing my own Entity Sorter, but
have not finished it.  The Ashwood version is fairly complex and hard
to debug, plus sometimes the sort order magically works out (the order
it calculates can vary from run-to-run), making it even harder to work
out.

Any chance you can tar up your model and send it along?  I won't be
able to look at it for a bit, but might have some time tonight or over
the weekend I could examine it.

mrg


On Fri, Nov 18, 2011 at 8:15 AM, Bruno René Santos <[email protected]> wrote:
> Hi Michael,
>
> They are all AUTO INCREMENT from MySQL. But when I check the queryLogger
> this happens because Cayenne tries to insert Object A before Object B when
> A has a foreign key to B and so B still has its OBjectId as TEMP.It seems
> to me Cayenne is failing to sort the objects for insertion correctly. Any
> way to check its insertion order or debug its algorithm?
>
> Regards
> Bruno
>
> On Fri, Nov 18, 2011 at 12:23 PM, Michael Gentry <[email protected]>wrote:
>
>> Hi Bruno,
>>
>> I believe that should be OK, so there must be something else going on.
>>  How are you generating your PKs?
>>
>> Thanks,
>>
>> mrg
>>
>>
>> On Fri, Nov 18, 2011 at 5:15 AM, Bruno René Santos <[email protected]>
>> wrote:
>> > Hi Michael,
>> >
>> > We dont have cyclic tables but we have some redundant paths like:
>> >
>> > A -> B -> C -> D
>> >
>> > A -> E -> C -> D
>> >
>> > Is this problematic?
>> >
>> > Regards
>> > Bruno
>> >
>> > On Thu, Nov 17, 2011 at 6:12 PM, Michael Gentry <[email protected]
>> >wrote:
>> >
>> >> Hi Bruno,
>> >>
>> >> The last time I saw this problem we had cyclic tables.  Something like:
>> >>
>> >> Table A -> Table B -> Table C -> Table D -> Table A
>> >>
>> >> Given this situation, Cayenne isn't able to properly do the inserts.
>> >> I *believe* this only applies to using autogenerated keys (are you
>> >> using MySQL?), though.
>> >>
>> >> mrg
>> >>
>> >>
>> >> On Thu, Nov 17, 2011 at 11:24 AM, Bruno René Santos <[email protected]
>> >
>> >> wrote:
>> >> > Hello all,
>> >> >
>> >> > I am getting this error on my application:
>> >> >
>> >> > org.apache.cayenne.CayenneRuntimeException: [v.3.0.1 Aug 25 2010
>> >> 19:38:17]
>> >> > Can't extract a master key. Missing key (id), master ID
>> >> > (<ObjectId:Avaliacao, TEMP:00000C43DB4942B7>)
>> >> >
>> >> > I can see on the logs that Cayenne is trying to insert an object that
>> >> needs
>> >> > a foreign key from another object that was not inserted yet... A past
>> >> post
>> >> > suggested that this could be a problem on the Model Map but we already
>> >> made
>> >> > it from scratch so we do not think that problem is there. My
>> application
>> >> > tries to clone a whole set of object into a new set objects (like
>> >> creating
>> >> > a complex structure from a template) and leaving a relationship of
>> object
>> >> > -> template between all objects that are part of the structure...
>> >> >
>> >> > Any one knows how can I check the rules on which order the objects
>> will
>> >> be
>> >> > inserted on the DB by the DataContext? Maybe somesort of check
>> function
>> >> > where I can see the current state of the Object Graph or something
>> like
>> >> > that?
>> >> >
>> >> > Regards
>> >> > Bruno Santos
>> >> >
>> >> > --
>> >> > Bruno René Santos | [email protected] | Gestor de Projectos |
>> Analista
>> >> |
>> >> > Programador | Investigador
>> >> >
>> >> > Holos - Soluções Avançadas em Tecnologias de Informação S.A.
>> >> > Parque de Ciência e Tecnologia de Almada/Setúbal . Edifício Madan
>> Parque
>> >> > Rua dos Inventores . Quinta da Torre . 2825 - 182 Caparica . Portugal
>> >> > Phone: +351 210 438 686 . Fax: +351 210 438 687 . Web: www.holos.pt
>> >> >
>> >> > This email and any files transmitted with it are confidential and
>> >> intended
>> >> > solely for the use of the individual or entity to whom they are
>> >> addressed.
>> >> > If you are not the intended recipient or the person responsible for
>> >> > delivering the email to the intended recipient, be advised that you
>> have
>> >> > received this email in error and that any use, dissemination,
>> forwarding,
>> >> > printing, or copying of this email is strictly prohibited. If you have
>> >> > received this email in error please notify Bruno René Santos by
>> telephone
>> >> > on +351 210 438 686
>> >> >
>> >>
>> >>
>> >
>> >
>> > --
>> > Bruno René Santos | [email protected] | Gestor de Projectos | Analista
>> |
>> > Programador | Investigador
>> >
>> > Holos - Soluções Avançadas em Tecnologias de Informação S.A.
>> > Parque de Ciência e Tecnologia de Almada/Setúbal . Edifício Madan Parque
>> > Rua dos Inventores . Quinta da Torre . 2825 - 182 Caparica . Portugal
>> > Phone: +351 210 438 686 . Fax: +351 210 438 687 . Web: www.holos.pt
>> >
>> > This email and any files transmitted with it are confidential and
>> intended
>> > solely for the use of the individual or entity to whom they are
>> addressed.
>> > If you are not the intended recipient or the person responsible for
>> > delivering the email to the intended recipient, be advised that you have
>> > received this email in error and that any use, dissemination, forwarding,
>> > printing, or copying of this email is strictly prohibited. If you have
>> > received this email in error please notify Bruno René Santos by telephone
>> > on +351 210 438 686
>> >
>>
>>
>
>
> --
> Bruno René Santos | [email protected] | Gestor de Projectos | Analista |
> Programador | Investigador
>
> Holos - Soluções Avançadas em Tecnologias de Informação S.A.
> Parque de Ciência e Tecnologia de Almada/Setúbal . Edifício Madan Parque
> Rua dos Inventores . Quinta da Torre . 2825 - 182 Caparica . Portugal
> Phone: +351 210 438 686 . Fax: +351 210 438 687 . Web: www.holos.pt
>
> This email and any files transmitted with it are confidential and intended
> solely for the use of the individual or entity to whom they are addressed.
> If you are not the intended recipient or the person responsible for
> delivering the email to the intended recipient, be advised that you have
> received this email in error and that any use, dissemination, forwarding,
> printing, or copying of this email is strictly prohibited. If you have
> received this email in error please notify Bruno René Santos by telephone
> on +351 210 438 686
>

Reply via email to