Skip to content

Commit f0732a5

Browse files
committed
#450 - Polishing.
Document version annotation.
1 parent d7a7660 commit f0732a5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main/asciidoc/reference/mapping.adoc

+8-3
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ Within the mapping framework it can be applied to constructor arguments.
174174
This lets you use a Spring Expression Language statement to transform a key’s value retrieved in the database before it is used to construct a domain object.
175175
In order to reference a column of a given row one has to use expressions like: `@Value("#root.myProperty")` where root refers to the root of the given `Row`.
176176
* `@Column`: Applied at the field level to describe the name of the column as it is represented in the row, allowing the name to be different than the field name of the class.
177+
* `@Version`: Applied at field level is used for optimistic locking and checked for modification on save operations.
178+
The value is `null` (`zero` for primitive types) is considered as marker for entities to be new.
179+
The initially stored value is `zero` (`one` for primitive types).
180+
The version gets incremented automatically on every update.
181+
See <<r2dbc.optimistic-locking>> for further reference.
177182

178183
The mapping metadata infrastructure is defined in the separate `spring-data-commons` project that is technology-agnostic.
179184
Specific subclasses are used in the R2DBC support to support annotation based metadata.
@@ -194,9 +199,9 @@ This works only if the parameter name information is present in the Java `.class
194199
----
195200
class OrderItem {
196201
197-
private @Id String id;
198-
private int quantity;
199-
private double unitPrice;
202+
private @Id final String id;
203+
private final int quantity;
204+
private final double unitPrice;
200205
201206
OrderItem(String id, int quantity, double unitPrice) {
202207
this.id = id;

0 commit comments

Comments
 (0)