diff --git a/inventory-service/src/main/java/com/example/inventoryservice/entities/Inventory.java b/inventory-service/src/main/java/com/example/inventoryservice/entities/Inventory.java index 7659d934..e928ab0c 100644 --- a/inventory-service/src/main/java/com/example/inventoryservice/entities/Inventory.java +++ b/inventory-service/src/main/java/com/example/inventoryservice/entities/Inventory.java @@ -1,6 +1,6 @@ /***

- Licensed under MIT License Copyright (c) 2021-2022 Raja Kolli. + Licensed under MIT License Copyright (c) 2021-2024 Raja Kolli.

***/ @@ -12,6 +12,7 @@ Licensed under MIT License Copyright (c) 2021-2022 Raja Kolli. import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.Table; +import jakarta.persistence.Version; @Entity @Table(name = "inventory") @@ -30,6 +31,8 @@ public class Inventory { @Column(name = "reserved_items") private Integer reservedItems = 0; + @Version private Short version; + public Long getId() { return id; } @@ -65,4 +68,13 @@ public Inventory setReservedItems(Integer reservedItems) { public Integer getReservedItems() { return reservedItems; } + + public Short getVersion() { + return version; + } + + public Inventory setVersion(Short version) { + this.version = version; + return this; + } } diff --git a/inventory-service/src/main/resources/db/changelog/migration/01-create_inventories_table.json b/inventory-service/src/main/resources/db/changelog/migration/01-create_inventories_table.json index 012352ee..1a8eb78c 100644 --- a/inventory-service/src/main/resources/db/changelog/migration/01-create_inventories_table.json +++ b/inventory-service/src/main/resources/db/changelog/migration/01-create_inventories_table.json @@ -77,6 +77,12 @@ "type": "INTEGER", "defaultValue": "0" } + }, + { + "column": { + "name": "version", + "type": "smallint" + } } ] }