class Ticket{
int id;
int caseId;
int orderNumber;
}
Lets imagine I can't change data structure. The order is always have to be without jumps (1,2,4 not good) in range of one caseId, every caseId will have to start from 1. Currently, records is being written in synchronized method, this is not scalable solution and there is a performance is actual issue here.
How can I use by Postgres DB to just throw the Ticket entities to it being certain that order number is always properly incremented on the db layer?