Re: how to specify objectId for new object

From: Eric Schneider (eri..entralparksoftware.com)
Date: Sat May 01 2004 - 22:36:21 EDT

  • Next message: Andrus Adamchik: "Re: Fw: Hibernate or Cayenne?"

    Brian,

    > But what if we (rarely) want to let the user specify the new object's id?

    You can do this by adding the pk columns as object attributes in your
    entity. The modeler leaves these pk columns out of the object entity by
    default. But, there is nothing that will stop you from adding them
    yourself. Setup this way, Cayenne will assume that the user will provide
    the value. Just set the property like you'd set any other.

    Cheers,
    Eric

    ----- Original Message -----
    From: "Bryan Lewis" <brya..aine.rr.com>
    To: <cayenne-use..bjectstyle.org>
    Sent: Saturday, May 01, 2004 3:18 PM
    Subject: how to specify objectId for new object

    > Most of the time we want a new object to get an auto-generated objectId,
    coming
    > from an Oracle sequence table for example. But what if we (rarely) want
    to let
    > the user specify the new object's id?
    >
    > I haven't been able to figure out how to set a new object's id. After
    looking
    > through the docs, I tried setObjectId() and setReplacementId(), both
    before and
    > after the initial commit of the object. All I've gotten is
    null-primary-key
    > exceptions. Is this doable? Thanks.
    >
    >



    This archive was generated by hypermail 2.0.0 : Sat May 01 2004 - 22:36:20 EDT