We have a java project that uses Hibernate as the OR Mapper. We need the project to work with both Oracle and Mysql. because some customers don’t want to install Oracle. we have added @sequenceGenerator annotation on entities to have sequence. but the project can not connect to Mysql DBMS with these annotations. Is there any way that we can have sequences in both mysql and Oracle mode, without any changes?
Share
Most portable way is to use TableGenerator. It is portable because no database provider specific constructs are used. Last generated value is stored to the database table, and value is retrieved and incremented via SQL queries.
Usage is also covered in Hibernate documentation.