Re: PostgreSQL sequences revisited

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Aug 02 2007 - 16:16:05 EDT

  • Next message: Andrus Adamchik (JIRA): "[JIRA] Created: (CAY-839) Support combination of Persistent objects and scalars in query results"

    Yeah, I've seen that attitude on PG JDBC list before (".... it's easy
    to get items added to the todo list.."). I can sympathize to an
    extent, as I am often reluctant to add things to Cayenne that don't
    feel right from where I am. Still this doesn't help that in this case
    such thing is a standard java.sql.Statement method. :-/

    So back to the original sequence naming discussion. Since we do not
    want to break our default implicit sequence naming for the existing
    installations of Cayenne, maybe approach it from the other end: on
    reverse engineering explicitly populate the sequence names for
    "serial" columns with PostgreSQL names? This way legacy DB's can be
    mapped with little effort.

    Do you think that'll work?

    Andrus

    On Aug 2, 2007, at 10:13 PM, Kevin Menard wrote:
    >> -----Original Message-----
    >> From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    >> Sent: Thursday, August 02, 2007 8:20 AM
    >> To: de..ayenne.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
    >



    This archive was generated by hypermail 2.0.0 : Thu Aug 02 2007 - 16:16:36 EDT