cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@welinux.cl
Subject Re: Table with no sequence
Date Fri, 20 Mar 2009 14:53:54 GMT
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" <mgentry@masslight.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,  <hans@welinux.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


Mime
View raw message