I am working on payroll project in java, struts2, spring and hibernate.
I need to generate employee-id automatically it can be numerical or alphanumerical, while iam saveing employee information in database the id wants to generate automatically and iam viewing employee information the with the employee-id the details wants to show . It can be possible or not please Guide me.
I am using SQL server 2008 database with hibernate mapping please give me some guide or some related website to solve my problem.
Hibernate supports auto generation of keys for non-floating numbers (int, long etc..). But if you need keys with alphanumeric then you might need to implement your own logic for generating them and assign the one just before you persist the entity.
Checkout the hibernate id generator class. For example if you use generator class: identity - hibernate will initiate automatically the id with a generated value by the database table identity column. Or you can use sequence and the id will be initiated with a sequence that you need to create in the database (named hibernate_sequence) etc. You can check the hibernate documentation for more details.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com