Generate Hibernate version tag for optimistic concurrency control
For Hibernate’s optimistic concurrency control to work, you need to add the version tag to mapping files. Here you will learn how to specify the version column in ERD entity so that concurrency control can be implemented in the generated ORM libraries.
Specifying Version Column
Create a version column in the entity that you want to generate version tag.
Right-click on the entity and select Open Specification...
from the popup menu. In the Entity Specification
dialog box, select the column in Version column
Right-click on the ERD, select Synchronize to Class Diagram
from the popup menu to update the class models.
You can see the version attribute appears in the associated class.
Generate code by selecting menu Tools > Object-Relational Mapping (ORM) > Generate Code....
If you selected to generate mapping as annotation, the version tag will appear in the corresponding source file as annotation.
If you selected to generate mapping as XML
, the version tag will appear in the corresponding mapping XML
as a node.