Re: Problem with sequences in PostgreSQL

From: Pierre Lavignotte (pierre.lavignott..mail.com)
Date: Fri Dec 05 2008 - 02:54:55 EST

  • Next message: Germán Mondragón: "Sequence postgres."

    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.andre..mail.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 <germa..elinux.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.
    > >
    > >
    > > use..ayenne.apache.org
    > >
    > >
    > > Thanks for reading
    > >
    >

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



    This archive was generated by hypermail 2.0.0 : Fri Dec 05 2008 - 02:55:40 EST