cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lindsay Steele <>
Subject Re: PK problem with Postgre
Date Fri, 21 Apr 2006 07:54:59 GMT
Andrus Adamchik wrote:
> create sequence foo_bar_seq;
> create table foo (bar integer unique not null default 
> nextval('foo_bar_seq'));
Yes,  I am using this way.

> (Or is this something else?) The example above does not work with 
> Cayenne because Postgres driver as of 8.0 does not implement 
> Statement.getGeneratedKeys() thus making it impossible (ok, rather 
> very hard) for Cayenne to retrieve the key generated in such way. The 
> solution - do not tie a PK column to a sequence in Postgres, let 
> Cayenne generate the key.
Maybe that explains things. I migrated from mysql so was hoping - or 
expecting it would work the same.

> I guess we may implement an equivalent of 
> 'Statement.getGeneratedKeys()' on Cayenne end by using Postgres 
> proprietary API to retrieve generated keys (and thus enable scenario 
> (1)), still I hoped the driver would provide that.
> Andrus
 Ok,  I understand that you need to know the generated key once a record 
is entered - which makes sense.

For now .. I did some more testing and will stick with my previous strategy.

View raw message