Search in sources :

Example 26 with Update

use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.

the class UpdateMapperUnitTests method shouldClearSet.

// DATACASS-343
@Test
void shouldClearSet() {
    Update update = updateMapper.getMappedObject(Update.empty().clear("set"), persistentEntity);
    assertThat(update.getUpdateOperations()).hasSize(1);
    assertThat(update).hasToString("set_col = {}");
}
Also used : Update(org.springframework.data.cassandra.core.query.Update) Test(org.junit.jupiter.api.Test)

Example 27 with Update

use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.

the class UpdateMapperUnitTests method shouldCreateIncrementUpdate.

// DATACASS-343
@Test
void shouldCreateIncrementUpdate() {
    Update update = updateMapper.getMappedObject(Update.empty().increment("number"), persistentEntity);
    assertThat(update.getUpdateOperations()).hasSize(1);
    assertThat(update).hasToString("number = number + 1");
}
Also used : Update(org.springframework.data.cassandra.core.query.Update) Test(org.junit.jupiter.api.Test)

Example 28 with Update

use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.

the class UpdateMapperUnitTests method shouldAppendToSet.

// DATACASS-770
@Test
void shouldAppendToSet() {
    Update update = updateMapper.getMappedObject(Update.empty().addTo("set").append(currencyEUR), persistentEntity);
    assertThat(update.getUpdateOperations()).hasSize(1);
    assertThat(update).hasToString("set_col = set_col + {'Euro'}");
}
Also used : Update(org.springframework.data.cassandra.core.query.Update) Test(org.junit.jupiter.api.Test)

Example 29 with Update

use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.

the class UpdateMapperUnitTests method shouldMapEmbeddedEntity.

// DATACASS-167
@Test
void shouldMapEmbeddedEntity() {
    Update update = this.updateMapper.getMappedObject(Update.empty().set("nested.firstname", "spring"), mappingContext.getRequiredPersistentEntity(WithNullableEmbeddedType.class));
    assertThat(update.getUpdateOperations()).hasSize(1);
    assertThat(update.toString()).startsWith("firstname = 'spring'");
}
Also used : Update(org.springframework.data.cassandra.core.query.Update) Test(org.junit.jupiter.api.Test)

Example 30 with Update

use of org.springframework.data.cassandra.core.query.Update in project spring-data-cassandra by spring-projects.

the class UpdateMapperUnitTests method shouldAppendAllToSetViaColumnNameCollectionOfElements.

// DATACASS-770
@Test
void shouldAppendAllToSetViaColumnNameCollectionOfElements() {
    Update update = updateMapper.getMappedObject(Update.empty().addTo("set_col").appendAll(new LinkedHashSet<>(Arrays.asList(currencyUSD, currencyEUR))), persistentEntity);
    assertThat(update.getUpdateOperations()).hasSize(1);
    assertThat(update).hasToString("set_col = set_col + {'US Dollar','Euro'}");
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Update(org.springframework.data.cassandra.core.query.Update) Test(org.junit.jupiter.api.Test)

Aggregations

Update (org.springframework.data.cassandra.core.query.Update)51 Test (org.junit.jupiter.api.Test)49 Query (org.springframework.data.cassandra.core.query.Query)15 WriteOptions (org.springframework.data.cassandra.core.cql.WriteOptions)7 Filter (org.springframework.data.cassandra.core.query.Filter)5 LinkedHashMap (java.util.LinkedHashMap)3 CqlIdentifier (com.datastax.oss.driver.api.core.CqlIdentifier)2 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)2 ClusteringOrder (com.datastax.oss.driver.api.core.metadata.schema.ClusteringOrder)2 BindMarker (com.datastax.oss.driver.api.querybuilder.BindMarker)2 QueryBuilder (com.datastax.oss.driver.api.querybuilder.QueryBuilder)2 Condition (com.datastax.oss.driver.api.querybuilder.condition.Condition)2 ConditionBuilder (com.datastax.oss.driver.api.querybuilder.condition.ConditionBuilder)2 Delete (com.datastax.oss.driver.api.querybuilder.delete.Delete)2 DeleteSelection (com.datastax.oss.driver.api.querybuilder.delete.DeleteSelection)2 Insert (com.datastax.oss.driver.api.querybuilder.insert.Insert)2 RegularInsert (com.datastax.oss.driver.api.querybuilder.insert.RegularInsert)2 ColumnRelationBuilder (com.datastax.oss.driver.api.querybuilder.relation.ColumnRelationBuilder)2 Relation (com.datastax.oss.driver.api.querybuilder.relation.Relation)2 Select (com.datastax.oss.driver.api.querybuilder.select.Select)2