This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate

 
P Arunkumar
Ranch Hand
Posts: 119
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bogdan Baraila
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic