OptimisticLocking exception during cascade delete

From: Bryan Lewis (jbryanlewi..mail.com)
Date: Thu Apr 15 2010 - 12:32:34 EDT

  • Next message: Bryan Lewis: "Re: OptimisticLocking exception during cascade delete"

    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 - 12:33:19 EDT