I need a unique alphanumeric code
for my entity.
It is not id. There is also id. But also, this code
field is unique.
It will be like this
"BS" + 6 alphanumeric chars
6 alphanumeric.
"BS" is default string. So , all of them will have "BS" in the start
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "id", updatable = false, nullable = false)
private Long id;
I am using spring boot. With hibernate, i can do such things but i need to make the size 8 or 6+2.
Also my sql has @Generator
but i could not manage to do
And each time, i dont want to get from db, increment and save. I think this is not good way?
What can i do? A custom generator
?
I looked for this also
https://stackoverflow.com/a/47934704/10309977
but could not a way to see to do
It will be around 1000 generations. So yearly aroudn 1-10 millions.