Re: Change of primary key - need to update others??

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sun Nov 28 2004 - 20:35:31 EST

  • Next message: Andrus Adamchik: "Re: Change of primary key - need to update others??"

    Hi there,

    I think it was mentioned in one of the recent threads (??), but you'll
    be better off defining a "meaningless" integer PK for category. This
    way (1) cayenne will generate it for you, (2) you can rename category
    without breaking any DB references. This of course assumes that you can
    control the schema...

    If you have to stay with current schema, Cayenne will not automatically
    update related tables [after all object identity is a cornerstone of an
    ORM, and here it is being destroyed], but Cayenne can help you finding
    those related objects so that you could do the update yourself.

    Cheers
    Andrus

    On Nov 28, 2004, at 6:31 AM, Alex Gunawan Wibowo wrote:
    > Hello...
    >
    > I have a question...
    > say my database schema is like this:
    >
    > category: _categoryName_ , status
    >
    > where categoryName is in String, and it's a primary
    > key.
    > Other tables are referring to this "category" table,
    > e.g.: product: _productId_, categoryName.
    >
    > If i change the categoryName of a record in "category"
    > table, do I need to look for all records in "product"
    > table that has the relationship to the "category"
    > table with the old categoryName, and set the new
    > categoryName?
    > or is cayenne smart enough to handle that in
    > background?
    >
    > Thanks a lot for the help!
    >
    > Best regards,
    >
    > Alex Wibowo.



    This archive was generated by hypermail 2.0.0 : Sun Nov 28 2004 - 20:35:36 EST