Want to write articles/new answer to be published in javapedia.net? Send in your article with your name to javatutorials2016@gmail.com!

Prev Next

Hibernate / SQL

Hi, I am Vinay, My question is how to create Empid (ex:Empid: TCS-456) and to save in Mysql BD, if next, I enter other then it should be incremented like Empid: TCS-456/7/8/9..etc.

Hi there, my suggestion would be using a DB sequence (or a separate table for the sequence in MYSQL DB) to generate a unique number (for example,456) and have a Database trigger (before-insert) to prefix "TCS-". This way we will make sure a unique id is generated. This solution completely relies on database objects.

if we want to achieve this using Java/hibernate, we can generate a unique number and prefix "TCS-".

❤Cash Back At Stores you Love !!!❤

Earn your $10 reward when you make your first purchase through Ebates by signing up with clicking below button.

Ebates Coupons and Cash Back

More Related questions...

Show more question and Answers...

Maven

Comments & Discussions