I am trying to create a Privilege class with Annotations whose Primary Key is a String. I will assign them manually while inserting. Therefore no need for hibernate to generate a value for it. I'm trying to do something like that:
@Id
@GeneratedValue(generator = "assigned")
@Column(name = "ROLE_NAME", nullable = false)
private String roleName;
But it throws that exception:
Caused by: org.hibernate.AnnotationException: Unknown Id.generator: assigned
How can I configure a String primary key with annotations?
Since the roleName is not auto-generated, you should simply not annotate it with @GeneratedValue:
@Id
@Column(name = "ROLE_NAME", nullable = false)
private String roleName;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With