Reputation: 1
I have a different product made from differents places. I need to create a custom key.
Product String id String name String description String source ...
Id is a String with this format and the counter must be reseted every year year-codsource-0000001 eg.
next year PT00A-00001 US00A-00001
I tried using @Tablegenerator and created a table CONTROL_IDS
PREFIX | COUNTER |
---|---|
PT00A | 1 |
US00A | 4 |
@TableGenerator(name = "idgen",table = "CONTROL_IDS",pkColumnName = "PREFIX",valueColumnName = "COUNTER",pkColumnValue = "PT00A", allocationSize=1)
Or even can select the prefix dinamically
@TableGenerator(name = "idgen", table = "CONTROL_IDS", pkColumnName = "PREFIX", valueColumnName = "COUNTER", pkColumnValue = "{prefixname}", allocationSize=1)
Thank you for any guide
I tried using @TableGenerator and @GenericGenerator and making a class to create prefixed value to the counter or exits other kind of generators?
Thank you for any guide.
Upvotes: 0
Views: 116