Re: Table with no sequence

From: han..elinux.cl
Date: Fri Mar 20 2009 - 10:53:54 EDT

  • Next message: Michael Gentry: "Re: Table with no sequence"

    Hi,

    Thank you for all the feedback, i can see that there is plenty of solutions that were not obvious at first. Yes I'm using 3.0.

    At first i thought i was committing a sin making this question, i smelled something religious against meaningful primary keys in legacy systems.

    Regards
    Hans

    ----- "Michael Gentry" <mgentr..asslight.net> escribió:

    > 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
    > >

    -- 
    Hans Poo, WeLinux S.A.
    Oficina: 697.25.42, Celular: 09-319.93.05
    Bombero Ossa # 1010, Santiago
    



    This archive was generated by hypermail 2.0.0 : Fri Mar 20 2009 - 10:58:27 EDT