uuid - Secure ID in Java with persistency -


i'm preparing java library need assign unique id generated objects serialization purposes. once unique id generated, have ensure next time use library, there no possibility reassign id object saved in past.

now, see many in stackoverflow suggest rely on couple of options, i.e. uuid, securerandom, i'm not sure classes suits needs , i'm not sure how use them.

please, can address myself right utility use , how generate id?

solutions based on utility guava/apache welcome.

the probability of generating duplicate uuids pretty low. i'm unaware of probability 2 uuid instances across different machines generate same id, uuids should unique across jvms. not go through trouble of embedding database generate uuids. can use java uuid safely.

alternate solution

if need unique id across multiple invocations of program, use database sequence. can ask db cache next n numbers of sequence make reasonable fast , value persisted across invocations. uuids more convenient use, both solutions work. if use db, know number of object you've serialized.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -