valchkou / cassandra-driver-mapping

JPA addon for DataStax Java Driver for Cassandra
58 stars 24 forks source link

Getting error while using BatchExecutor for multible tables using condition IF NOT EXIST #66

Open rahulsrivastava71 opened 9 years ago

rahulsrivastava71 commented 9 years ago

Dear Eugene, I wanted to use batchexecutor for executing multiple queries on multiple tables with IF NOT EXIST (@Version in mapper) condition as i when i am running the batchexecutor i am getting error "Batch with Condition cannot span multiple tables". While when i am executing batch on single table with IF NOT EXIST(@Version in mapper) condition its is executing but when i am changing the partition key it gives error "Batch with condition cannot span same partition key ". As i have to perform batch execution with different partition key keeping IF NOT EXIST feature is there any way out to do this. Or have i got any alternate solution to execute batch on multiple table keeping IF NOT EXIST feature.

valchkou commented 9 years ago

Hi Rahul, There is no rules inside my module, but Cassandra has certain restrictions and limitations and we have to live with it. The one you are faced is something I can't control from my module. Batch is very dumb. I just construct CQL statements from the Entities and pass them over to Datastax Driver batch executor. All I think of is to split your batch statements so that you don't brake Cassandra rules.

Btw, what is the main reason for you to use batch?

rahulsrivastava71 commented 9 years ago

Dear Eugene , We were trying to execute queries through Batch because we needed Atomicity for roll-back as we need roll-back scenario which we can use using batch as if single query in batch fails then all queries of my batch gets overturned.

rahulsrivastava71 commented 9 years ago

Can you please help me out in finding the reason that why do you have used synchronised(lock) block while executing the batch executor as there is any specific reason behind it .

valchkou commented 9 years ago

Not sure where you see synchronized while executing batch https://github.com/valchkou/cassandra-driver-mapping/blob/master/src/main/java/com/datastax/driver/mapping/MappingSession.java lines 695, 705

The only place where synchronized used is when my module have to generate the schema from the entity.