Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete does not take any options #71

Open
jalger98 opened this issue Oct 20, 2015 · 4 comments
Open

Delete does not take any options #71

jalger98 opened this issue Oct 20, 2015 · 4 comments

Comments

@jalger98
Copy link

There is no way to provide options to the delete methods of the MappingSession or BatchExecutor. Delete should take options like the WriteOptions supported for the save methods. We could use the timestamp and consistencyLevel options immediately. retryPolicy would be nice too.

@jalger98
Copy link
Author

Adding a timestamp option to the BatchExecutor BatchOptions would also be helpful.

@valchkou
Copy link
Owner

I will take a look at it

@jalger98
Copy link
Author

Awesome, thanks!

@jalger98
Copy link
Author

I was able to modify the logic of the buildDelete method in the MappingBuilder as a simple proof of the logic being there. However, your current "master" branch has 2.2.0-rc2 which does not support the format that code I'm about to suggest. It is written with the syntax for cassandra-driver-core version 2.1.3. Obviously, you'd have to update the signature to support passing in the options instead of the hardcoded version below but this seems to confirm that it could be retrofitted fairly easily.

public static <T> Delete buildDelete(EntityTypeMetadata entityMetadata, List<String> pkCols, Object[] values, String keyspace) {
    String table = entityMetadata.getTableName();
    Delete delete = QueryBuilder.delete().from(keyspace, table);

    // Apply the timestamp here.
    delete.using(timestamp(System.currentTimeMillis()*1000));

    for (int i = 0; i < values.length; i++) {
        delete.where(eq(pkCols.get(i), values[i]));
    }
    return delete;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants