Hi,
I would like to create an ID for every entity, but I want to make it randomly generated. How am I going to do that?
Hi,
I would like to create an ID for every entity, but I want to make it randomly generated. How am I going to do that?
Hi,
You can easily generate random numbers using org.apache.commons.lang3.RandomUtils
.
But, you should know that it is not suitable for ID of entities because it generates non globally unique values. I’d recommend that you use standard UUID type instead or take a look at UniqueNumbersAPI
on Sequence Generation page of the manual.
Can you give me the example of full code that can generate random ID? Because I’m new to this application and I am still learning how to code.