Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

How to make Custom UUID or ID in Hibernate?

 
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • 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..
 
Bartender
Posts: 10336
Hibernate Eclipse IDE 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?
 
Pay attention! Tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic