Last active
July 21, 2016 06:48
-
-
Save mp911de/a5f26274272da3c3de051a8fd55a62f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class CassandraInQuery { | |
| @Autowired | |
| CassandraOperations cassandraOperations; | |
| @Test | |
| public void query() { | |
| List<String> values = Arrays.asList("one", "two", "three"); | |
| List<MyEntity> result = new ArrayList<>(); | |
| // one-by-one | |
| for (String value : values) { | |
| Select select = QueryBuilder.select().from("mytable"); | |
| select.where(QueryBuilder.eq("a", value)).and(QueryBuilder.eq("b", "a-static-value")); | |
| result.addAll(cassandraOperations.select(select, MyEntity.class)); | |
| } | |
| // in-query | |
| Select select = QueryBuilder.select().from("mytable"); | |
| select.where(QueryBuilder.in("a", values)).and(QueryBuilder.eq("b", "a-static-value")); | |
| result = cassandraOperations.select(select, MyEntity.class); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment