Re: PK problem with Postgre

From: Lindsay Steele (lsteel..inet.net.au)
Date: Fri Apr 21 2006 - 03:54:59 EDT

  • Next message: Borut Bolčin: "MySql AUTO_PK_SUPPORT"

    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.



    This archive was generated by hypermail 2.0.0 : Fri Apr 21 2006 - 03:54:08 EDT