From 15422ea13bdf602b6c408e88750c6418fab173b9 Mon Sep 17 00:00:00 2001 From: Gavin Date: Thu, 18 May 2023 11:20:56 +0200 Subject: [PATCH] improve section on versions --- documentation/src/main/asciidoc/introduction/Entities.adoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/documentation/src/main/asciidoc/introduction/Entities.adoc b/documentation/src/main/asciidoc/introduction/Entities.adoc index cd8064fa92..780e5f99de 100644 --- a/documentation/src/main/asciidoc/introduction/Entities.adoc +++ b/documentation/src/main/asciidoc/introduction/Entities.adoc @@ -448,7 +448,7 @@ Book book = session.find(Book.class, new BookId(isbn, printing)); === Version attributes An entity may have an attribute which is used by Hibernate for optimistic lock checking. -A version attribute is usually of type `Integer` or `LocalDateTime`, though several other types are also allowed. +A version attribute is usually of type `Integer`, `Short`, `Long`, `LocalDateTime`, `OffsetDateTime`, `ZonedDateTime`, or `Instant`. [source,java] ---- @@ -456,7 +456,7 @@ A version attribute is usually of type `Integer` or `LocalDateTime`, though seve LocalDateTime lastUpdated; ---- -The `@Id` and `@Version` attributes we've already seen are just specialized examples of _basic attributes_. +Version attributes are automatically assigned by Hibernate when an entity is made persistent, and automatically incremented or updated each time the entity is updated. [TIP] // .Optimistic locking in Hibernate @@ -466,6 +466,8 @@ The `@OptimisticLocking` annotation lets us specify that optimistic locks should And the `@OptimisticLock` annotation lets us selectively exclude certain fields from optimistic locking. ==== +The `@Id` and `@Version` attributes we've already seen are just specialized examples of _basic attributes_. + [[natural-id-attributes]] === Natural id attributes