30
30
import org .springframework .data .cassandra .repository .support .SchemaTestUtils ;
31
31
import org .springframework .data .cassandra .test .util .AbstractKeyspaceCreatingIntegrationTests ;
32
32
33
+ import com .datastax .oss .driver .api .core .cql .BatchType ;
33
34
import com .datastax .oss .driver .api .core .cql .ResultSet ;
34
35
import com .datastax .oss .driver .api .core .cql .Row ;
35
36
@@ -64,7 +65,7 @@ void setUp() throws Exception {
64
65
@ Test // DATACASS-288
65
66
void shouldInsertEntities () {
66
67
67
- CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template );
68
+ CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template , BatchType . LOGGED );
68
69
batchOperations .insert (walter ).insert (mike ).execute ();
69
70
70
71
Group loaded = template .selectOneById (walter .getId (), Group .class );
@@ -89,7 +90,7 @@ void shouldInsertEntitiesWithLwt() {
89
90
90
91
walter .setAge (100 );
91
92
92
- CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template );
93
+ CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template , BatchType . LOGGED );
93
94
94
95
WriteResult writeResult = batchOperations .insert (walter , lwtOptions ).insert (mike ).execute ();
95
96
@@ -108,7 +109,7 @@ void shouldInsertEntitiesWithLwt() {
108
109
@ Test // DATACASS-288
109
110
void shouldInsertCollectionOfEntities () {
110
111
111
- CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template );
112
+ CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template , BatchType . LOGGED );
112
113
batchOperations .insert (Arrays .asList (walter , mike )).execute ();
113
114
114
115
Group loaded = template .selectOneById (walter .getId (), Group .class );
@@ -125,7 +126,7 @@ void shouldInsertCollectionOfEntitiesWithTtl() {
125
126
int ttl = 30 ;
126
127
WriteOptions options = WriteOptions .builder ().ttl (30 ).build ();
127
128
128
- CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template );
129
+ CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template , BatchType . LOGGED );
129
130
batchOperations .insert (Arrays .asList (walter , mike ), options ).execute ();
130
131
131
132
ResultSet resultSet = template .getCqlOperations ().queryForResultSet ("SELECT TTL(email) FROM group;" );
@@ -149,7 +150,7 @@ void shouldUpdateEntities() {
149
150
walter .
setEmail (
"[email protected] " );
150
151
mike .
setEmail (
"[email protected] " );
151
152
152
- CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template );
153
+ CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template , BatchType . LOGGED );
153
154
batchOperations .update (walter ).update (mike ).execute ();
154
155
155
156
Group loaded = template .selectOneById (walter .getId (), Group .class );
@@ -163,7 +164,7 @@ void shouldUpdateCollectionOfEntities() {
163
164
walter .
setEmail (
"[email protected] " );
164
165
mike .
setEmail (
"[email protected] " );
165
166
166
- CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template );
167
+ CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template , BatchType . LOGGED );
167
168
batchOperations .update (Arrays .asList (walter , mike )).execute ();
168
169
169
170
Group loaded = template .selectOneById (walter .getId (), Group .class );
@@ -180,7 +181,7 @@ void shouldUpdateCollectionOfEntitiesWithTtl() {
180
181
int ttl = 30 ;
181
182
WriteOptions options = WriteOptions .builder ().ttl (ttl ).build ();
182
183
183
- CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template );
184
+ CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template , BatchType . LOGGED );
184
185
batchOperations .update (walter , options ).execute ();
185
186
186
187
ResultSet resultSet = template .getCqlOperations ().queryForResultSet ("SELECT TTL(email), email FROM group" );
@@ -209,7 +210,7 @@ void shouldUpdatesCollectionOfEntities() {
209
210
walter .
setEmail (
"[email protected] " );
210
211
mike .
setEmail (
"[email protected] " );
211
212
212
- CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template );
213
+ CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template , BatchType . LOGGED );
213
214
batchOperations .update (Arrays .asList (walter , mike )).execute ();
214
215
215
216
FlatGroup loaded = template .selectOneById (walter , FlatGroup .class );
@@ -226,7 +227,7 @@ void deleteAsVarargsShouldRejectQueryOptions() {
226
227
@ Test // DATACASS-288
227
228
void shouldDeleteEntities () {
228
229
229
- CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template );
230
+ CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template , BatchType . LOGGED );
230
231
231
232
batchOperations .delete (walter ).delete (mike ).execute ();
232
233
@@ -238,7 +239,7 @@ void shouldDeleteEntities() {
238
239
@ Test // DATACASS-288
239
240
void shouldDeleteCollectionOfEntities () {
240
241
241
- CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template );
242
+ CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template , BatchType . LOGGED );
242
243
243
244
batchOperations .delete (Arrays .asList (walter , mike )).execute ();
244
245
@@ -255,7 +256,7 @@ void shouldApplyTimestampToAllEntities() {
255
256
256
257
long timestamp = (System .currentTimeMillis () + TimeUnit .DAYS .toMillis (1 )) * 1000 ;
257
258
258
- CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template );
259
+ CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template , BatchType . LOGGED );
259
260
batchOperations .insert (walter ).insert (mike ).withTimestamp (timestamp ).execute ();
260
261
261
262
ResultSet resultSet = template .getCqlOperations ().queryForResultSet ("SELECT writetime(email) FROM group;" );
@@ -270,7 +271,7 @@ void shouldApplyTimestampToAllEntities() {
270
271
@ Test // DATACASS-288
271
272
void shouldNotExecuteTwice () {
272
273
273
- CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template );
274
+ CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template , BatchType . LOGGED );
274
275
batchOperations .insert (walter ).execute ();
275
276
276
277
assertThatIllegalStateException ().isThrownBy (() -> batchOperations .execute ());
@@ -279,7 +280,7 @@ void shouldNotExecuteTwice() {
279
280
@ Test // DATACASS-288
280
281
void shouldNotAllowModificationAfterExecution () {
281
282
282
- CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template );
283
+ CassandraBatchOperations batchOperations = new CassandraBatchTemplate (template , BatchType . LOGGED );
283
284
batchOperations .insert (walter ).execute ();
284
285
285
286
assertThatIllegalStateException ().isThrownBy (() -> batchOperations .update (new Group ()));
0 commit comments