Re: Violation of PRIMARY KEY constraint

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sat Nov 22 2003 - 15:52:58 EST

  • Next message: Leonardo R. Nunes: "RE: Violation of PRIMARY KEY constraint"

    On Nov 22, 2003, at 2:47 PM, Leonardo R. Nunes wrote:

    > Does cayenne verify if a new object
    > (dataContext.createAndRegisterNewObject(“MyDataObjectClassName”))
    > violates a primary key ?
    > Or do I need query the database before create a newDataObject?
    >
    >
    > If I need query the database before … is there a way to query the
    > objects that was not “commited” ?

    Hi Leonardo,

    I don't know if you've been watching this thread over the past few
    days, but it answers all your questions:

    http://objectstyle.org/cayenne/lists/cayenne-user/2003/11/0067.html

    A short summary of this discussion:

    * If you have a meaningful PK that is also a property of a Java class,
    it is your responsibility to ensure that you assign a previously unused
    value. Otherwise Cayenne will do it for you.
    * SelectQueries are for database data only, so new uncommitted objects
    are not included in the query results.

    Andrus



    This archive was generated by hypermail 2.0.0 : Sat Nov 22 2003 - 15:53:03 EST