File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed 
spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 1515 */ 
1616package  org .springframework .data .cassandra .core ;
1717
18+ import  com .datastax .oss .driver .api .core .ConsistencyLevel ;
1819import  java .util .Arrays ;
1920import  java .util .concurrent .atomic .AtomicBoolean ;
2021
4243 * @since 1.5 
4344 */ 
4445class  CassandraBatchTemplate  implements  CassandraBatchOperations  {
46+ //public class CassandraBatchTemplate implements CassandraBatchOperations { 
4547
4648	private  final  AtomicBoolean  executed  = new  AtomicBoolean ();
4749
@@ -60,8 +62,7 @@ class CassandraBatchTemplate implements CassandraBatchOperations {
6062	 * 
6163	 * @param operations must not be {@literal null}. 
6264	 */ 
63- 	CassandraBatchTemplate (CassandraOperations  operations ) {
64- 
65+ 	public  CassandraBatchTemplate (CassandraOperations  operations ) {
6566		Assert .notNull (operations , "CassandraOperations must not be null" );
6667
6768		this .operations  = operations ;
@@ -70,6 +71,16 @@ class CassandraBatchTemplate implements CassandraBatchOperations {
7071		this .statementFactory  = new  StatementFactory (new  UpdateMapper (converter ));
7172	}
7273
74+ 	/** 
75+ 	 * Create a new {@link CassandraBatchTemplate} given {@link CassandraOperations} with {@link ConsistencyLevel}. 
76+ 	 * 
77+ 	 * @param operations must not be {@literal null}. 
78+ 	 */ 
79+ 	public  CassandraBatchTemplate (CassandraOperations  operations , ConsistencyLevel  consistencyLevel ) {
80+ 		this (operations );
81+ 		batch .setConsistencyLevel (consistencyLevel );
82+ 	}
83+ 
7384	/** 
7485	 * Return a reference to the configured {@link CassandraConverter} used to map {@link Object Objects} to 
7586	 * {@link com.datastax.driver.core.Row Rows}. 
Original file line number Diff line number Diff line change 1515 */ 
1616package  org .springframework .data .cassandra .core ;
1717
18+ import  com .datastax .oss .driver .api .core .ConsistencyLevel ;
1819import  java .util .Iterator ;
1920import  java .util .List ;
2021import  java .util .stream .Stream ;
@@ -58,6 +59,14 @@ public interface CassandraOperations extends FluentCassandraOperations {
5859	 */ 
5960	CassandraBatchOperations  batchOps ();
6061
62+ 	/** 
63+ 	 * Returns a new {@link CassandraBatchOperations}. Each {@link CassandraBatchOperations} instance can be executed only 
64+ 	 * once so you might want to obtain new {@link CassandraBatchOperations} instances for each batch. 
65+ 	 * 
66+ 	 * @return a new {@link CassandraBatchOperations} associated with the given entity class. 
67+ 	 */ 
68+ 	CassandraBatchOperations  batchOps (ConsistencyLevel  consistencyLevel );
69+ 
6170	/** 
6271	 * Expose the underlying {@link CqlOperations} to allow CQL operations. 
6372	 * 
Original file line number Diff line number Diff line change 1515 */ 
1616package  org .springframework .data .cassandra .core ;
1717
18+ import  com .datastax .oss .driver .api .core .ConsistencyLevel ;
1819import  java .util .List ;
1920import  java .util .function .Consumer ;
2021import  java .util .function .Function ;
@@ -202,6 +203,12 @@ public CassandraBatchOperations batchOps() {
202203		return  new  CassandraBatchTemplate (this );
203204	}
204205
206+ 	@ Override 
207+ 	public  CassandraBatchOperations  batchOps (ConsistencyLevel  consistencyLevel ) {
208+ 		return  new  CassandraBatchTemplate (this , consistencyLevel );
209+ 	}
210+ 
211+ 
205212	/* (non-Javadoc) 
206213	 * @see org.springframework.context.ApplicationEventPublisherAware#setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) 
207214	 */ 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments