Re: OptimisticLocking exception during cascade delete

From: Bryan Lewis (jbryanlewi..mail.com)
Date: Thu Apr 15 2010 - 14:43:26 EDT

  • Next message: Andrus Adamchik: "Re: Connection Pool"

    Hmm, that's very strange. Now the double deletion isn't happening. I don't
    think I changed anything relevant but I can't make it happen now. Oh well,
    never mind.

    On Thu, Apr 15, 2010 at 12:32 PM, Bryan Lewis <jbryanlewi..mail.com> wrote:

    > I have an entity Quote with a to-many relationship to QuoteCountry, and a
    > cascade delete rule. When I delete a quote object, Cayenne attempts to
    > delete the QuoteCountry objects twice, I suspect because I also have a
    > flattened relationship quote.countries (Quote -> QuoteCountry -> Country).
    >
    > I was googling for previous reports of this and found none, but I did come
    > across an old copy of Cayenne's DataContext.java that explicitly checked for
    > deleting twice in the presence of a flattened relationship.
    >
    > Normally this double deletion might not be noticed, but it throws an
    > OptimisticLockException if optimistic locking is enabled on the Quote
    > entity. My current work-around is to disable OL on this entity only, which
    > isn't a bad work-around for me. BatchAction does:
    >
    > int updated = statement.executeUpdate();
    > if (useOptimisticLock && updated != 1) {
    > //...
    > throw new OptimisticLockException(...);
    >
    >



    This archive was generated by hypermail 2.0.0 : Thu Apr 15 2010 - 14:44:27 EDT