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

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Nov 29 2004 - 23:35:40 EST

  • Next message: Andrus Adamchik: "Re: Evaluating Cayenne for Java Client application"

    Hi Oliver

    > Cant you create a relationship that will cascade the
    > update of the pk on the db?

    That's an interesting idea... I've never tried it, but many dbs should
    support that... The only trick is to invalidate related objects
    in-memory if there are any... I posted a "pure Cayenne" approach here
    just a few minutes back, but yours may actually be cleaner...

    http://objectstyle.org/cayenne/lists/cayenne-user/2004/11/0182.html

    and I am asking the same thing - please send your comments to the
    mailing list, so that others could benefit from this discussion as well
    ;-)

    Andrus

    On Nov 29, 2004, at 10:19 PM, Oliver Layug wrote:
    > Hi,
    >
    > Cant you create a relationship that will cascade the
    > update of the pk on the db?
    >
    > Cheers,
    > Oliver
    >
    >
    > --- Andrus Adamchik <andru..bjectstyle.org> wrote:
    >
    >> 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.
    >>
    >>
    >
    >
    >
    >
    > __________________________________
    > Do you Yahoo!?
    > Take Yahoo! Mail with you! Get it on your mobile phone.
    > http://mobile.yahoo.com/maildemo
    >



    This archive was generated by hypermail 2.0.0 : Mon Nov 29 2004 - 23:35:45 EST