Announcement Announcement Module
No announcement yet.
To use or not to use MySQLMaxValueIncrementer Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    You could use one increment table and a row per increment counter with two columns - increment name and value.