This is a problem with your mapping. If you wish to manage primary keys
yourself, map the DB attribute for the primary key as an object entity. If
not, use the modeller to create the necessary tables for generated primary
keys (auto_pk_support). To quote thy docs:
"When a new DataObject is saved, and its properties and relationships do
not contain primary key values, Cayenne would attempt to automatically
generate a key value. Generation mechanism depends on DbAdapter used and
can be customized by users by subclassing one of the included adapters.
Current Cayenne adapters use the following mechanisms:
MySQL, PostgreSQL, HSQL Adapter: use select/update from a special
AUTO_PK_TABLE lookup table."
Cayenne is trying to get the next primary key value, and is trying to
access the AUTO_PK_TABLE.
Scott
Quoting Laurence Gellert <geller..arkwing.uoregon.edu>:
> 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:26:52 EDT