@@ -236,6 +236,20 @@ public static DataBoostQueryOption dataBoostEnabled(Boolean dataBoostEnabled) {
236
236
return new DataBoostQueryOption (dataBoostEnabled );
237
237
}
238
238
239
+ /**
240
+ * If set to true, this option marks the end of the transaction. The transaction should be
241
+ * committed or aborted after this statement executes, and attempts to execute any other requests
242
+ * against this transaction (including reads and queries) will be rejected. Mixing mutations with
243
+ * statements that are marked as the last statement is not allowed.
244
+ *
245
+ * <p>For DML statements, setting this option may cause some error reporting to be deferred until
246
+ * commit time (e.g. validation of unique constraints). Given this, successful execution of a DML
247
+ * statement should not be assumed until the transaction commits.
248
+ */
249
+ public static LastStatementUpdateOption lastStatementSet (Boolean lastStatementSet ) {
250
+ return new LastStatementUpdateOption (lastStatementSet );
251
+ }
252
+
239
253
/**
240
254
* Specifying this will cause the list operation to start fetching the record from this onwards.
241
255
*/
@@ -495,6 +509,8 @@ void appendToOptions(Options options) {
495
509
private RpcOrderBy orderBy ;
496
510
private RpcLockHint lockHint ;
497
511
512
+ private Boolean lastStatementSet ;
513
+
498
514
// Construction is via factory methods below.
499
515
private Options () {}
500
516
@@ -630,6 +646,14 @@ OrderBy orderBy() {
630
646
return orderBy == null ? null : orderBy .proto ;
631
647
}
632
648
649
+ boolean hasLastStatementSet () {
650
+ return lastStatementSet != null ;
651
+ }
652
+
653
+ Boolean lastStatementSet () {
654
+ return lastStatementSet ;
655
+ }
656
+
633
657
boolean hasLockHint () {
634
658
return lockHint != null ;
635
659
}
@@ -694,6 +718,9 @@ public String toString() {
694
718
if (orderBy != null ) {
695
719
b .append ("orderBy: " ).append (orderBy ).append (' ' );
696
720
}
721
+ if (lastStatementSet != null ) {
722
+ b .append ("lastStatementSet: " ).append (lastStatementSet ).append (' ' );
723
+ }
697
724
if (lockHint != null ) {
698
725
b .append ("lockHint: " ).append (lockHint ).append (' ' );
699
726
}
@@ -737,6 +764,7 @@ public boolean equals(Object o) {
737
764
&& Objects .equals (dataBoostEnabled (), that .dataBoostEnabled ())
738
765
&& Objects .equals (directedReadOptions (), that .directedReadOptions ())
739
766
&& Objects .equals (orderBy (), that .orderBy ())
767
+ && Objects .equals (lastStatementSet (), that .lastStatementSet ());
740
768
&& Objects .equals (lockHint (), that .lockHint ());
741
769
}
742
770
@@ -797,6 +825,9 @@ public int hashCode() {
797
825
if (orderBy != null ) {
798
826
result = 31 * result + orderBy .hashCode ();
799
827
}
828
+ if (lastStatementSet != null ) {
829
+ result = 31 * result + lastStatementSet .hashCode ();
830
+ }
800
831
if (lockHint != null ) {
801
832
result = 31 * result + lockHint .hashCode ();
802
833
}
@@ -965,4 +996,18 @@ public boolean equals(Object o) {
965
996
return Objects .equals (filter , ((FilterOption ) o ).filter );
966
997
}
967
998
}
999
+
1000
+ static final class LastStatementUpdateOption extends InternalOption implements UpdateOption {
1001
+
1002
+ private final Boolean lastStatementSet ;
1003
+
1004
+ LastStatementUpdateOption (Boolean lastStatementSet ) {
1005
+ this .lastStatementSet = lastStatementSet ;
1006
+ }
1007
+
1008
+ @ Override
1009
+ void appendToOptions (Options options ) {
1010
+ options .lastStatementSet = lastStatementSet ;
1011
+ }
1012
+ }
968
1013
}
0 commit comments