views:

23

answers:

1

Hi, I am now using hibernate as ORM technique in my application. I have a table called Order and I want the hibernate to generates the ID for each instance when inserting new order into the table. Quite unusual, the desired auto-generated id should be something like this:

first time: jialhe001 and then jialhe002 .... jialhe003, jialhe004......

How can I realize that? I have found some articles talking about creating a new class which implements the identifier generator interface and override a method.

However, the explanation is quite general no detailed thing. Can anyone tell me how to do that? Preferably, code sample is highly requested. Thank you in advance.

A: 

I'd argue that you should not use such primary keys if you can use a simple auto_increment. If your application needs the string jialhe00x then concatenate jialhe with the auto-incremented ID.

You didn't say which articles you read, so check this one

Bozho