Problem with sequences in PostgreSQL

From: Germán Mondragón (germa..elinux.cl)
Date: Thu Dec 04 2008 - 16:45:50 EST

  • Next message: Alex Gallo: "RE: Problem with cayenne accessing mixed tables in Postgresql"

    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 : Thu Dec 04 2008 - 16:49:46 EST