I would like to add a user defined column which will auto increment on new record insertion, how should I do this? so that it runs on h2, mysql
@Entity public class Parent {
@OneToMany List<Child> children;
}
@Entity public class Child {
int sortOrder;
}
e.g. Parent1 has Child{1, 2, 3}
Parent2 has {1, 2}
Note: Values within each Parent needs to be auto incremented not outside.
Set the Id type as identity, and the DB tbale should handle the Identity insertion.
sample,