Forums Register Login

Hibernate primary Key/User defined Generator class

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
    joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 4338 times.
    Similar Threads
    cascade-delete doesn't work
    Firing of Character method of Defualt Handler
    problem in request.getparameter
    one to many mapping
    primary key class of entity beans?
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 28, 2024 15:32:04.