This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Does DataFieldMaxValueIncrementer achieve portability? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Does DataFieldMaxValueIncrementer achieve portability?" Watch "Does DataFieldMaxValueIncrementer achieve portability?" New topic
Author

Does DataFieldMaxValueIncrementer achieve portability?

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

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

Joined: Jan 23, 2002
Posts: 11962
    
    5
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.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

For PostgreSQL database, I use:

But for MySQL database, there is no sequence to name.
What to do?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You pass in the name of the table you use to simulate a sequence, then, like the javadocs suggest.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Does DataFieldMaxValueIncrementer achieve portability?
 
Similar Threads
Auto increment the Varchar datatype
random numbers
Manually incremented keys
autoincrement invoice
Unknown table 'sequences' in information_schema