Re: Canonical objects

From: Mike Kienenberger (mkienen..mail.com)
Date: Sat Sep 03 2005 - 20:36:12 EDT

  • Next message: Mike Kienenberger: "Re: ObjectId immutability?"

    You'd have to do the same thing in Cayenne, or another workaround (try
    to insert the object and throw it away if you get a constraint
    violation exception). You're going to have race conditions if you
    check, then create, then insert. That said, I have used the same
    process.

    I wonder if a better workaround might be to create a psuedo-optimistic
    lock on your unique keys.

    On 9/3/05, Gili <cowwo..bs.darktech.org> wrote:
    > Hi,
    >
    > Say I have:
    >
    > table ImageSpecification [id, width, height]
    >
    > In Hibernate if I created a new ImageSpecification in my application
    > and I wanted to save it into the database only if it didn't already
    > exist (i.e. canonicalization) I would have to manually invoke something
    > like this:
    >
    > mySpecification = mySpecification.getCanonicalInstance()
    >
    > where getCanonicalInstance() is a method I implemented to issue a DB
    > query and if an equivilent object was found in the DB return it;
    > otherwise return "this". In this way I would ensure that I never ended
    > up with two copies in the database of the same specification.
    >
    > Would I have to do the same with Cayenne or is there a cleaner way?
    >
    > Thank you,
    > Gili
    > --
    > http://www.desktopbeautifier.com/
    >



    This archive was generated by hypermail 2.0.0 : Sat Sep 03 2005 - 20:36:14 EDT