24
24
import org .springframework .util .Assert ;
25
25
26
26
import com .couchbase .client .java .kv .GetOptions ;
27
+ import com .couchbase .transactions .AttemptContextReactive ;
27
28
28
29
public class ExecutableFindByIdOperationSupport implements ExecutableFindByIdOperation {
29
30
@@ -35,7 +36,7 @@ public class ExecutableFindByIdOperationSupport implements ExecutableFindByIdOpe
35
36
36
37
@ Override
37
38
public <T > ExecutableFindById <T > findById (Class <T > domainType ) {
38
- return new ExecutableFindByIdSupport <>(template , domainType , null , null , null , null , null );
39
+ return new ExecutableFindByIdSupport <>(template , domainType , null , null , null , null , null , null );
39
40
}
40
41
41
42
static class ExecutableFindByIdSupport <T > implements ExecutableFindById <T > {
@@ -47,19 +48,21 @@ static class ExecutableFindByIdSupport<T> implements ExecutableFindById<T> {
47
48
private final GetOptions options ;
48
49
private final List <String > fields ;
49
50
private final Duration expiry ;
51
+ private final AttemptContextReactive txCtx ;
50
52
private final ReactiveFindByIdSupport <T > reactiveSupport ;
51
53
52
54
ExecutableFindByIdSupport (CouchbaseTemplate template , Class <T > domainType , String scope , String collection ,
53
- GetOptions options , List <String > fields , Duration expiry ) {
55
+ GetOptions options , List <String > fields , Duration expiry , AttemptContextReactive txCtx ) {
54
56
this .template = template ;
55
57
this .domainType = domainType ;
56
58
this .scope = scope ;
57
59
this .collection = collection ;
58
60
this .options = options ;
59
61
this .fields = fields ;
60
62
this .expiry = expiry ;
63
+ this .txCtx = txCtx ;
61
64
this .reactiveSupport = new ReactiveFindByIdSupport <>(template .reactive (), domainType , scope , collection , options ,
62
- fields , expiry , new NonReactiveSupportWrapper (template .support ()));
65
+ fields , expiry , txCtx , new NonReactiveSupportWrapper (template .support ()));
63
66
}
64
67
65
68
@ Override
@@ -75,29 +78,35 @@ public Collection<? extends T> all(final Collection<String> ids) {
75
78
@ Override
76
79
public TerminatingFindById <T > withOptions (final GetOptions options ) {
77
80
Assert .notNull (options , "Options must not be null." );
78
- return new ExecutableFindByIdSupport <>(template , domainType , scope , collection , options , fields , expiry );
81
+ return new ExecutableFindByIdSupport <>(template , domainType , scope , collection , options , fields , expiry , txCtx );
79
82
}
80
83
81
84
@ Override
82
85
public FindByIdWithOptions <T > inCollection (final String collection ) {
83
- return new ExecutableFindByIdSupport <>(template , domainType , scope , collection , options , fields , expiry );
86
+ return new ExecutableFindByIdSupport <>(template , domainType , scope , collection , options , fields , expiry , txCtx );
84
87
}
85
88
86
89
@ Override
87
90
public FindByIdInCollection <T > inScope (final String scope ) {
88
- return new ExecutableFindByIdSupport <>(template , domainType , scope , collection , options , fields , expiry );
91
+ return new ExecutableFindByIdSupport <>(template , domainType , scope , collection , options , fields , expiry , txCtx );
89
92
}
90
93
91
94
@ Override
92
95
public FindByIdInScope <T > project (String ... fields ) {
93
96
Assert .notEmpty (fields , "Fields must not be null." );
94
- return new ExecutableFindByIdSupport <>(template , domainType , scope , collection , options , Arrays .asList (fields ), expiry );
97
+ return new ExecutableFindByIdSupport <>(template , domainType , scope , collection , options , Arrays .asList (fields ),
98
+ expiry , txCtx );
95
99
}
96
100
97
101
@ Override
98
102
public FindByIdWithProjection <T > withExpiry (final Duration expiry ) {
99
- return new ExecutableFindByIdSupport <>(template , domainType , scope , collection , options , fields ,
100
- expiry );
103
+ return new ExecutableFindByIdSupport <>(template , domainType , scope , collection , options , fields , expiry , txCtx );
104
+ }
105
+
106
+ @ Override
107
+ public FindByIdWithExpiry <T > transaction (AttemptContextReactive txCtx ) {
108
+ Assert .notNull (txCtx , "txCtx must not be null." );
109
+ return new ExecutableFindByIdSupport <>(template , domainType , scope , collection , options , fields , expiry , txCtx );
101
110
}
102
111
103
112
}
0 commit comments