@@ -236,6 +236,20 @@ public static DataBoostQueryOption dataBoostEnabled(Boolean dataBoostEnabled) {
236236 return new DataBoostQueryOption (dataBoostEnabled );
237237 }
238238
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+
239253 /**
240254 * Specifying this will cause the list operation to start fetching the record from this onwards.
241255 */
@@ -495,6 +509,8 @@ void appendToOptions(Options options) {
495509 private RpcOrderBy orderBy ;
496510 private RpcLockHint lockHint ;
497511
512+ private Boolean lastStatementSet ;
513+
498514 // Construction is via factory methods below.
499515 private Options () {}
500516
@@ -630,6 +646,14 @@ OrderBy orderBy() {
630646 return orderBy == null ? null : orderBy .proto ;
631647 }
632648
649+ boolean hasLastStatementSet () {
650+ return lastStatementSet != null ;
651+ }
652+
653+ Boolean lastStatementSet () {
654+ return lastStatementSet ;
655+ }
656+
633657 boolean hasLockHint () {
634658 return lockHint != null ;
635659 }
@@ -694,6 +718,9 @@ public String toString() {
694718 if (orderBy != null ) {
695719 b .append ("orderBy: " ).append (orderBy ).append (' ' );
696720 }
721+ if (lastStatementSet != null ) {
722+ b .append ("lastStatementSet: " ).append (lastStatementSet ).append (' ' );
723+ }
697724 if (lockHint != null ) {
698725 b .append ("lockHint: " ).append (lockHint ).append (' ' );
699726 }
@@ -737,6 +764,7 @@ public boolean equals(Object o) {
737764 && Objects .equals (dataBoostEnabled (), that .dataBoostEnabled ())
738765 && Objects .equals (directedReadOptions (), that .directedReadOptions ())
739766 && Objects .equals (orderBy (), that .orderBy ())
767+ && Objects .equals (lastStatementSet (), that .lastStatementSet ());
740768 && Objects .equals (lockHint (), that .lockHint ());
741769 }
742770
@@ -797,6 +825,9 @@ public int hashCode() {
797825 if (orderBy != null ) {
798826 result = 31 * result + orderBy .hashCode ();
799827 }
828+ if (lastStatementSet != null ) {
829+ result = 31 * result + lastStatementSet .hashCode ();
830+ }
800831 if (lockHint != null ) {
801832 result = 31 * result + lockHint .hashCode ();
802833 }
@@ -965,4 +996,18 @@ public boolean equals(Object o) {
965996 return Objects .equals (filter , ((FilterOption ) o ).filter );
966997 }
967998 }
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+ }
9681013}
0 commit comments