Re: AUTO_INCREMENT pk generation in MySQL

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Oct 27 2004 - 21:29:33 EDT

  • Next message: Derek Rendall: "Re: Prefetching and paginated queries"

    On Oct 27, 2004, at 8:09 PM, Robert Bundy wrote:

    > I am starting an implement of this according to the previous posting:
    >
    > http://www.objectstyle.org/cayenne/lists/cayenne-user/2004/09/
    > 0172.html
    >  
    > I assume that I can subclass MySQLPkGenerator to first do a query:
    >      SELECT LAST_INSERT_ID() FROM customer LIMIT 1;
    > to get the next pk and then increment it after that to get each
    > successive pk.
    > This only works if no one else is updating this table.  Is there a way
    > around this problem?
    >  
    > Robert Bundy
    > 720-339-1397
    >

    Hmm.. now re-reading your original post, looks like I misunderstood you
    back then, and gave an incorrect advise. I thought you were talking
    about using a different table name for pk lookup, but now reading you
    new message and checking MySQL docs, I see that you are talking about
    auto-increment feature (e.g.
    http://dev.mysql.com/doc/mysql/en/example-AUTO_INCREMENT.html).

    Unfortunately in this case there is no reliable way to do it just by
    subclassing an adapter - it requires changes in the DataContext commit
    flow. Good news is that this feature will be in Cayenne *very* soon,
    likely in a matter of weeks -
    http://objectstyle.org/cayenne/lists/cayenne-user/2004/10/0144.html

    Andrus



    This archive was generated by hypermail 2.0.0 : Wed Oct 27 2004 - 21:29:38 EDT