use of org.springframework.data.cassandra.core.query.Query in project spring-data-cassandra by spring-projects.
the class StatementFactoryUnitTests method shouldCreateSetUpdate.
// DATACASS-343
@Test
void shouldCreateSetUpdate() {
Query query = Query.query(Criteria.where("foo").is("bar"));
StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update = statementFactory.update(query, Update.empty().set("firstName", "baz").set("boo", "baa"), personEntity);
assertThat(update.build(ParameterHandling.INLINE).getQuery()).isEqualTo("UPDATE person SET first_name='baz', boo='baa' WHERE foo='bar'");
}
use of org.springframework.data.cassandra.core.query.Query in project spring-data-cassandra by spring-projects.
the class StatementFactoryUnitTests method shouldMapSelectQueryIsNotNull.
// DATACASS-549
@Test
void shouldMapSelectQueryIsNotNull() {
Query query = Query.query(Criteria.where("foo").isNotNull()).columns(Columns.from("age"));
StatementBuilder<Select> select = statementFactory.select(query, groupEntity);
assertThat(select.build(ParameterHandling.INLINE).getQuery()).isEqualTo("SELECT age FROM group WHERE foo IS NOT NULL");
}
use of org.springframework.data.cassandra.core.query.Query in project spring-data-cassandra by spring-projects.
the class StatementFactoryUnitTests method shouldMapSelectQueryWithSortLimitAndAllowFiltering.
// #1008
@Test
void shouldMapSelectQueryWithSortLimitAndAllowFiltering() {
Query query = Query.empty().sort(Sort.by(DESC, "email", "age"));
StatementBuilder<Select> select = statementFactory.select(query, converter.getMappingContext().getRequiredPersistentEntity(Group.class));
assertThat(select.build(ParameterHandling.INLINE).getQuery()).isEqualTo("SELECT * FROM group ORDER BY email DESC,age DESC");
}
use of org.springframework.data.cassandra.core.query.Query in project spring-data-cassandra by spring-projects.
the class CassandraTemplateIntegrationTests method deleteByQueryShouldRemoveEntity.
// DATACASS-343
@Test
void deleteByQueryShouldRemoveEntity() {
User user = new User("heisenberg", "Walter", "White");
template.insert(user);
Query query = Query.query(where("id").is("heisenberg"));
assertThat(template.delete(query, User.class)).isTrue();
assertThat(template.selectOneById(user.getId(), User.class)).isNull();
}
use of org.springframework.data.cassandra.core.query.Query in project spring-data-cassandra by spring-projects.
the class CassandraTemplateIntegrationTests method selectByQueryWithKeyspaceShouldRetrieveData.
// DATACASS-767
@Test
void selectByQueryWithKeyspaceShouldRetrieveData() {
assumeThat(cassandraVersion.isGreaterThanOrEqualTo(CASSANDRA_4)).isTrue();
QueryOptions queryOptions = QueryOptions.builder().keyspace(CqlIdentifier.fromCql(keyspace)).build();
User user = new User("heisenberg", "Walter", "White");
template.insert(user);
Query query = Query.query(where("id").is("heisenberg")).queryOptions(queryOptions);
assertThat(template.select(query, User.class)).isNotEmpty();
}
Aggregations