> -----Original Message----- > From: Andrus Adamchik [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 02, 2007 8:20 AM > To: dev@cayenne.apache.org > Subject: Re: PostgreSQL sequences revisited > > A question - would serial type work as an auto-increment? I.e. is it > possible to run PreparedStatement like this (notice no PK in the > statement): > > INSERT INTO ARTIST (NAME) VALUES (?)
This indeed works (no real surprise). > And then get back DB-generated ARTIST_ID via > java.sql.Statement.getGeneratedKeys()? I suspect no, but if it is, it > would be a really nice improvement to PG adapter. This does not. The JDBC driver does not support it, per: http://gborg.postgresql.org/project/pgjdbc/bugs/bugupdate.php?984 http://archives.postgresql.org/pgsql-jdbc/2004-09/msg00190.php In my quick investigation, it appears the addition of the RETURNING clause to DML statements may help push through an implementation of getGeneratedKeys(). The RETURNING clause was only recently added in 8.2 though, so it would not degrade nicely for us. We could issue curval() calls, but things could get funky for batched INSERTs, I imagine. -- Kevin