Guest User

Untitled

a guest
Oct 23rd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. public List<Person> findByFirstNameAndDateOfBirth(String firstName, LocalDate dateOfBirth) {
  2. return cassandraTemplate
  3. .getCqlOperations()
  4. .query(
  5. findByFirstNameAndDateOfBirthQuery(firstName, dateOfBirth),
  6. (row, rowNum) -> cassandraTemplate.getConverter().read(Person.class, row));
  7. }
  8.  
  9. private BoundStatement findByFirstNameAndDateOfBirthQuery(
  10. String firstName, LocalDate dateOfBirth) {
  11. return CachedPreparedStatementCreator.of(
  12. cache,
  13. select()
  14. .all()
  15. .from("people_by_first_name")
  16. .where(eq("first_name", bindMarker("first_name")))
  17. .and(eq("date_of_birth", bindMarker("date_of_birth"))))
  18. .createPreparedStatement(session)
  19. .bind()
  20. .setString("first_name", firstName)
  21. .setDate("date_of_birth", toCqlDate(dateOfBirth));
  22. }
Add Comment
Please, Sign In to add comment