Re: Problem with sequences in PostgreSQL

From: Andrey Razumovsky (razumovsky.andre..mail.com)
Date: Fri Dec 05 2008 - 02:36:48 EST

  • Next message: Andrey Razumovsky: "Re: Problem with cayenne accessing mixed tables in Postgresql"

    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
    >



    This archive was generated by hypermail 2.0.0 : Fri Dec 05 2008 - 02:37:22 EST