aspose file tools
The moose likes Object Relational Mapping and the fly likes Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Hibernate" Watch "Hibernate" New topic
Author

Hibernate

P Arunkumar
Ranch Hand

Joined: Jan 05, 2012
Posts: 116
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: 3670

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Hibernate
 
Similar Threads
Hibernate beginer
Hibernate Installation
how to call a jsp function with in a hyperlink
Hibernate association mapping
Using Struts2 to xml format Hibernate objects