File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate" Watch "Hibernate" New topic
Author

Hibernate

P Arunkumar
Ranch Hand

Joined: Jan 05, 2012
Posts: 119
Hi

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.


Please guide me.

Thanks in advance.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3860

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.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Bogdan Baraila
Ranch Hand

Joined: May 23, 2011
Posts: 43
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate