Re: Table with no sequence

From: Michael Gentry (mgentr..asslight.net)
Date: Fri Mar 20 2009 - 09:59:05 EDT

  • Next message: han..elinux.cl: "Re: Table with no sequence"

    If you assign your primary key(s) manually, before telling Cayenne to
    commitChanges(), then you'll be fine. Cayenne will honor the PK value
    that you set without trying to replace it.

    You didn't mention which version of Cayenne, but for version 2.0 (and
    I suppose even in 3.0) you can override your data object's
    setPersistenceState() method:

      public void setPersistenceState(int state)
      {
        super.setPersistenceState(state);

        if (state == PersistenceState.NEW)
        {
           // Initialize PK here.
        }
      }

    For Cayenne 3.0, you can use the new lifecycle callbacks:

    http://cayenne.apache.org/doc/lifecycle-callbacks.html

    mrg

    On Thu, Mar 19, 2009 at 7:07 PM, <han..elinux.cl> wrote:
    > Hi,
    >
    > We have a legacy table that have a meaningful primary key, many code depends on it and it's not possible to alter it.
    > We are building new java applications that need to insert in it.
    >
    > We would like to cayenne it and not use any sequence at all for making inserts...
    >
    > ¿ it's possible to do it ?
    >
    > Regards
    > Hans
    >



    This archive was generated by hypermail 2.0.0 : Fri Mar 20 2009 - 09:59:42 EDT