postgres PK serial column insert error

From: Laurence Gellert (geller..arkwing.uoregon.edu)
Date: Mon Aug 02 2004 - 15:10:03 EDT

  • Next message: Scott McClure: "Re: postgres PK serial column insert error"

    Hi,
    I'm using postgres 7.3.3 as my backend. My goal is to add a new record to
    the database. I've already got a context, and can select records just fine.
    When I try to commit the add it errors out when trying to get the next value
    for loginid, the pk.

    javax.servlet.ServletException: [v.1.1B2 July 25 2004] Commit Exception

    Caused by: java.sql.SQLException: ERROR: Relation "auto_pk_support" does
    not exist

    I would like to do something along the lines of making an INSERT statement
    like: "INSERT INTO login (username, password) VALUES ('test', 'abc');"

    Instead, it looks like Cayenne is accessing 'auto_pk_support' for the next
    login id. This is two trips to the db, instead of one.

    My code:
    Login newLogin = (Login) context.createAndRegisterNewObject(Login.class);
    newLogin.setUsername("test");
    newLogin.setPassword("abc");
    context.commitChanges();

    Table:
    CREATE TABLE public.Login (
           LoginID SERIAL NOT NULL
         , Username VARCHAR(30)
         , Password VARCHAR(30)
         , PRIMARY KEY (LoginID)
    );

    Please help! Thanks!

    Laurence Gellert



    This archive was generated by hypermail 2.0.0 : Mon Aug 02 2004 - 15:10:07 EDT