You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you would like to retrieve it, you can add a field of `com.google.cloud.Timestamp` type to your entity and annotate it with `@UpdateTime` annotation.
327
+
328
+
[source,java,indent=0]
329
+
----
330
+
@UpdateTime
331
+
Timestamp updateTime;
332
+
----
333
+
334
+
===== Using update time for optimistic locking
335
+
A field annotated with `@UpdateTime` can be used for optimistic locking.
336
+
To enable that, you need to set `version` parameter to `true`:
337
+
338
+
[source,java,indent=0]
339
+
----
340
+
@UpdateTime(version = true)
341
+
Timestamp updateTime;
342
+
----
343
+
344
+
When you enable optimistic locking, a precondition will be automatically added to the write request to ensure that the document you are updating was not changed since your last read.
345
+
It uses this field's value as a document version and checks that the version of the document you write is the same as the one you've read.
346
+
347
+
If the field is empty, a precondition would check that the document with the same id does not exist to ensure you don't overwrite existing documents unintentionally.
348
+
324
349
=== Cloud Firestore Spring Boot Starter
325
350
326
351
If you prefer using Firestore client only, Spring Cloud GCP provides a convenience starter which automatically configures authentication settings and client objects needed to begin using https://cloud.google.com/firestore/[Google Cloud Firestore] in native mode.
Copy file name to clipboardExpand all lines: spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/firestore/GcpFirestoreAutoConfiguration.java
+4-4
Original file line number
Diff line number
Diff line change
@@ -131,8 +131,8 @@ public FirestoreMappingContext firestoreMappingContext() {
Copy file name to clipboardExpand all lines: spring-cloud-gcp-data-firestore/src/main/java/com/google/cloud/spring/data/firestore/FirestoreTemplate.java
Copy file name to clipboardExpand all lines: spring-cloud-gcp-data-firestore/src/main/java/com/google/cloud/spring/data/firestore/mapping/FirestoreClassMapper.java
Copy file name to clipboardExpand all lines: spring-cloud-gcp-data-firestore/src/main/java/com/google/cloud/spring/data/firestore/mapping/FirestoreDefaultClassMapper.java
Copy file name to clipboardExpand all lines: spring-cloud-gcp-data-firestore/src/main/java/com/google/cloud/spring/data/firestore/mapping/FirestorePersistentEntity.java
+2
Original file line number
Diff line number
Diff line change
@@ -44,4 +44,6 @@ public interface FirestorePersistentEntity<T> extends
Copy file name to clipboardExpand all lines: spring-cloud-gcp-data-firestore/src/main/java/com/google/cloud/spring/data/firestore/mapping/FirestorePersistentEntityImpl.java
Copy file name to clipboardExpand all lines: spring-cloud-gcp-data-firestore/src/main/java/com/google/cloud/spring/data/firestore/transaction/ReactiveFirestoreResourceHolder.java
+6
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,8 @@ public class ReactiveFirestoreResourceHolder extends ResourceHolderSupport {
Copy file name to clipboardExpand all lines: spring-cloud-gcp-data-firestore/src/main/java/com/google/cloud/spring/data/firestore/transaction/ReactiveFirestoreTransactionManager.java
0 commit comments