cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Lewis <jbryanle...@gmail.com>
Subject OptimisticLocking exception during cascade delete
Date Thu, 15 Apr 2010 16:32:34 GMT
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(...);

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message