I have encountered a quite complex but genuine issue with my application design. Some predefined data is to be given through shell script which is mentioned below:
INSERT INTO config.profile_backend_point_asso(assoc_id,enabled,end_point_id,profile_id) VALUES (1,true,1,1), (2,true,2,1);
Note:- “assoc_id” is defined as the primary key.
Now user can also give some custom entries through UI for which “assoc_id” are generated using hibernate sequence.
Let’s say hibernate allotted 3 as “assoc_id” for which entry in the table will be (3,true,3,1);
At some point of time, the requirement for predefined entries increases and we allotted below entries in table unknowingly what hibernate has generated in past on UI operations.
Now, this “assoc_id” has already been allotted and will give constraint violation exception.
So can we have any solution to synchronize these two approaches of primary key allotment so that whether its shell script or UI using hibernate sequence will allot the unique id every time.