I want to generate a UUID in a spring controller. I am new to this and I studied the following
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private String corrId;
I don't want to bind this uuid to any database column / field, but I want it to be unique (I'm not sure if this is possible)
When I try to print the String 'corrId' value, it always gives me null
I also tried, but the value of corrId is still null
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private String corrId;
I'm doing something wrong here, or my approach is completely wrong.
Thanks in advance!
source
share