Results 1 to 2 of 2

Thread: To use or not to use MySQLMaxValueIncrementer

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Posts
    16

    Default To use or not to use MySQLMaxValueIncrementer

    Just finished (for the most part) ProSpring. Am creating my data access layer using Dao classes. Underlying DB is MySQL. All tables use an integer primary key. Naturally, auto-increment seems like a perfect fit. The book advises against using it since determining the assigned value requires a post SELECT last_insert_id() which could possibly have been incremented by another process.

    I have successfully implemented my solution with the MySQLMaxValueIncrementer, but this requires a second table for each table that I have, essentially doubling the number of tables. Not that this is a crime, but it seems excessive. Since the book was written before Spring version 2.0, is the use of last_insert_id() still a problem, or can it be used safely now with the newer version of Spring?

    Thanks in advance for any help.

  2. #2
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    You could use one increment table and a row per increment counter with two columns - increment name and value.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •