My question is an extension to this, this and my own previous question.
After loads of other readings too, I have the following in my Entity:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "useruuid")
@GenericGenerator(name = "uuid", strategy = "uuid4")
private String useruuid;
Question 1: Are above declarations valid? @Id is for sure yes as we all know it. The question is more focussed on @GenericGenerator(name = "uuid", strategy = "uuid4").
Meaning Generating UUIDs in the Entity which already has @GeneratedValue
. Is it acceptable? I tried it and it works.
Question 2: If above is yes, then would the generated UUID as String will be unique for entire DB or just for the Entity only? I am seeking help here as I would use the same pattern in my rest of the Entities in the same Database.