Re: Unique fields

From: Steve Wells (stwell..wnmail.net)
Date: Wed Oct 06 2004 - 05:32:08 EDT

  • Next message: Mike Kienenberger: "Re: Cayenne presentation by Michael Sacket"

    Thanks all for your responses.

    OK now I've thought this through for a bit and I agree that Cayenne
    shouldn't be doing the DB work for this. Thanks for the clarifications
    on my initial thoughts of getting Cayenne to automate what I would
    *perhaps* have to do manually.

    While I'm getting out of my depth here, I still wonder if the Cayenne
    modeller should define the index options for a DB Entity.
    This still lets the DB do the work and the developer can define the
    index
    (in my case the unique index/constraint) in the modeller knowing that
    the DB will
    have the constraint in place. The developer wouldn't have to worry
    about
    maintaining indexes for different DB types and ensuring that the index
    is set.

    If I set a unique index now and try to insert, I'll get an
    Exception...right? So I'm a little unsure as to why there'd be a
    need to check all possible DB error codes and track possible changes
    between releases of both DB and JDBC driver (though probably nice to
    have). Could we just use
    the same exception mechanism?

    I could manually set a unique index on my DB, but from a selfish lazy
    user perspective this is maintenance. I could maintain a script of
    indexes. But what if I want to move to a new db that has a different
    syntax?

    Sorry if all this sounds like the ravings of a madman but its just my
    thoughts.

    ----- Original message -----
    From: "Andrus Adamchik" <andru..bjectstyle.org>
    To: cayenne-use..bjectstyle.org
    Date: Tue, 5 Oct 2004 19:22:53 -0400
    Subject: Re: Unique fields

    Trying to answer a few emails in this thread at once ;-)

    On Oct 5, 2004, at 10:22 AM, Gentry, Michael wrote:
    > I could see an option for putting it in the model for the purpose of
    > schema creation

    That's the only thing I had in mind when proposing to open a ticket in
    JIRA. I definitely have no intentions to force Cayenne doing the DB
    work.

    On Oct 5, 2004, at 10:52 AM, Cris Daniluk wrote (also mentioned by
    Stefaan Huysentruyt)
    > Why not let the database do it and simply have the db adapters better
    > equipped to handle the unique constraint exception? Oracle, PG, MySQL
    > all have a unique constraint and all throw a consistent (though
    > different)
    > exception.

    That's an interesting idea, however this is also lots of maintenance
    burden to keep an internal mapping of all possible DB error codes and
    track possible changes between releases of both DB and JDBC driver. So
    it will be hard to achieve consistency here...

    Andrus



    This archive was generated by hypermail 2.0.0 : Wed Oct 06 2004 - 05:32:13 EDT