cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pierre Lavignotte" <pierre.lavigno...@gmail.com>
Subject Re: Problem with sequences in PostgreSQL
Date Fri, 05 Dec 2008 07:54:55 GMT
Hi,

If you choose "Database-Generated", Cayenne will try to use a sequence named
"PK_TABLENAME".
You have to choose "Custom Sequence" to specify you own name.

The "Cache PK Size" value is the number of IDs that Cayenne will try to use
with one call to your sequence.
In Oracle, this value corresponds to the "INCREMENT_BY" sequence value and
NOT to the "CACHE_SIZE" sequence value.

When "Database-Generated", I think this value is 20 by default so this can
cause unexpected behaviour if your sequence is not set accordingly.

Hope this helps,
Pierre


On Fri, Dec 5, 2008 at 8:36 AM, Andrey Razumovsky <
razumovsky.andrey@gmail.com> wrote:

> Cayenne's default strategy uses extra table, "auto_pk_support". Obviously
> other apps working with your DB do not use this table. You should change PK
> Generation strategy to 'Database Sequence' or something
>
> 2008/12/5, Germán Mondragón <german@welinux.cl>:
> >
> > Hi,
> >
> > Hello, i have an application that must live with other applications
> > inserting rows in a table.
> >
> > The problem is that cayenne postgresql adapter don't increment the
> sequence
> > according to the number of rows inserted, this provokes an inconsistency
> > with the ids in the table and the last value in the sequence. As a
> > consequence when the other external program try to insert rows, the call
> to
> > nextval generates a duplicate primary key, and the application crashes.
> >
> > I've configured web.xml parameters the next way:
> >   <init-param>
> >         <param-name>shared-cache</param-name>
> >         <param-value>false</param-value>
> > </init-param>
> >
> > And cayenne maps this way:
> > <db-entity name="test_a" schema="public">
> >                  <db-attribute name="descripcion" type="VARCHAR"
> > length="100"/>
> >                  <db-attribute name="id_test" type="INTEGER"
> > isPrimaryKey="true" isMandatory="true"/>
> > </db-entity>
> >
> > <obj-entity name="TestA" className="TestA" dbEntityName="test_a">
> >                  <obj-attribute name="descripcion"
> type="java.lang.String"
> > db-attribute-path="descripcion"/>
> > </obj-entity>
> >
> >
> > Pk Generation strategy = Default.
> >
> >
> > user@cayenne.apache.org
> >
> >
> > Thanks for reading
> >
>



-- 
Cordialement,
Pierre Lavignotte
Ingénieur Conception & Développement
http://pierre.lavignotte.googlepages.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message