I have a table like this in sybase
uuid | varchar
parent_uuid | varchar
entity_version | int
with a composite unique constraint based on parent_uuid and entity_version.
I am looking at auto incrementing entity_version based on this constraint.
So the first insert for parent_uuid = ‘ABC’ will be 0 and later inserts will take in value 1,2,3 …
We have a hibernate based java application. However there are support occurrences where this table could be updated by bypassing hibernate so I would rather use something which could auto increment this value in the db.
Is there a way outside writing a trigger/ procedure
Hibernate is not for mainating the consitency iof its accessed from more than otherw ay too. Database trigger is the way, but if you have only on/few such requirement. If its peppered in your application. You need something else. Like Distibuted database or distributed cache only having access to your database. Lone case, trigger will do. And May be a consol/main/web class invoking that trigger from hibernate too just to have a single set of OIRM too there. Hope that helps