Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does DataFieldMaxValueIncrementer achieve portability?

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
We are using Spring JDBC support classes to access the database.
Currently, we are using PostgreSQL as the development and testing database but the production system could be MySQL.
ID columns are sequences (auto increment for MySQL in the future plan).
I found this utility class:
DataFieldMaxValueIncrementer
with implementation for different RDBMS (PostgreSQL, MySQL, DB2 ...)
Can I depend on it to achieve portability between PostgreSQL sequences and MySQL auto-increment columns?
Thanks.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's the idea - you abstract away the source of the unique IDs for your persistent objects, thereby making the potential migration from PostgreSQL to MySQL a matter of setting up the new database schema and reconfiguring your application with a different incrementer implementation.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For PostgreSQL database, I use:

But for MySQL database, there is no sequence to name.
What to do?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You pass in the name of the table you use to simulate a sequence, then, like the javadocs suggest.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic