• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make Custom UUID or ID in Hibernate?

 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends...

i have a little question about UUID Hibernate..
as we know that UUID in Hibernate generate hexadecimal 16bytes...

ussually the hexadecimal value which generated like this one :


is it possible to create custom UUID?..
example the result like this :


i just wanna put 1 character in front of that UUID to distinguish each branch office..

ussualy i've done configuration like this :


--------------------------------------------------------------------------------------------------------

or is it possible to create custom ID?..
i want to create ID like this (in varchar/String data type). :



or maybe like this :



Thanks in advanced..
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i just wanna put 1 character in front of that UUID to distinguish each branch office..

Why do you want to introduce business meaning to a surrogate key? Doesn't that mean you wiuyld need to update your key when a branch office is changed? If so, would it not be better to add a new attribute to your entity called branch office?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic