I have two columns which will use @GeneratedValues, but when I am putting them like this it is giving error; \" Exception Description: Class [class Testing] has two @GeneratedVa
Using columnDefinition="serial" with Postgresql it works for me.
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(columnDefinition="serial")
@Generated(GenerationTime.INSERT)
private Long seqNo;
Like the error message says, Only one field with @GeneratedValue
is allowed but you have two.
Please remove one of them.
I am afraid you can't do what you intended by simple annotations.
Check out this existing post for workaround.
workaround
Not sure why you need two columns in same table, whose value need to be auto incremented.
If you really want two Unique columns, you can use your id as usual and UUID for the other column.