I am trying to automatically generate alpha-numberic primary keys (e.g. TESLA1001) in Hibernate. I am currently using an Oracle database, so I have a JDBC call to my_sequence.NEXTVAL (1002) to increase the number and add to the prefix (TESLA).
We consider MySQL as an option, but they do not support sequences. Therefore, I am forced to rewrite the method of generating a user identifier by calling JDBC in a stored procedure.
Is there any way to create a common implementation to create custom primary keys without using JDBC queries and databases? So, in the future, if I need to test my application using MSSQL, I only need to change my hiberate configuration and everything will work fine!
source share