what’s the easiest way to implement a string id in jpa ?
So far what I have is
@Id
@GeneratedValue
private int id;
and what I’d like to have is something like
@Id
@GeneratedValue
private String id;
but if I use it like this, I get ‘this id generator generates long, integer, short’.
You can create the UUID from Java like this:
Or if your JPA supports it, like Hibernate does, you can use:
Checkout this blogpost for details.
If you google for “JPA UUID” there are many alternatives.