• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate primary Key/User defined Generator class

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi It may be a basic question.. but I am unable to find any answer for this..
I have a table Employee which have a column Emp_id,Emp_name and salary where Emp_id is primary key.
My Problem is My Emp_id should be like <CompanyName><SequenceNo> (eg. 'JAVA1','JAVA2','JAVA3') like this.
How to create this sequence?

Thanks & Regards,
Raj
 
Rajkumar Kathiresan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After a day Night spent over this problem I found solution for this
I give my own generator class NextSequence which implements the org.hibernate.id.IdentifierGenerator


my NextSequence class looks like


Now I have two problem

  • It bring value "Java9" as max value even i have a value "Java10". Is it any possible way to get the value "Java10" as max value
  • Its still specific to one Entity. It is possible to make it generalized one, where i can use this NextSequence class for all my tables.
    Like For Author my id would be like "Au001","Au002", etc.
    Help me on this.
    Thankx in advance
    Raja
     
    reply
      Bookmark Topic Watch Topic
    • New Topic