use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldDeleteColumns.
@Test
public void shouldDeleteColumns() {
String columnFamily = "columnFamily";
ColumnDeleteQuery query = delete("column", "column2").from(columnFamily).build();
assertThat(query.getColumns(), containsInAnyOrder("column", "column2"));
assertFalse(query.getCondition().isPresent());
assertEquals(columnFamily, query.getColumnFamily());
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class AbstractColumnTemplate method delete.
@Override
public <T, K> void delete(Class<T> entityClass, K id) {
requireNonNull(entityClass, "entityClass is required");
requireNonNull(id, "id is required");
ClassMapping classMapping = getClassMappings().get(entityClass);
FieldMapping idField = classMapping.getId().orElseThrow(() -> IdNotFoundException.newInstance(entityClass));
Object value = ConverterUtil.getValue(id, classMapping, idField.getFieldName(), getConverters());
ColumnDeleteQuery query = ColumnDeleteQuery.delete().from(classMapping.getName()).where(idField.getName()).eq(value).build();
getManager().delete(query);
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class BaseColumnRepository method getDeleteQuery.
protected ColumnDeleteQuery getDeleteQuery(Method method, Object[] args) {
DeleteMethodProvider deleteMethodFactory = DeleteMethodProvider.get();
DeleteQuery deleteQuery = deleteMethodFactory.apply(method, getClassMapping().getName());
ColumnDeleteQueryParams queryParams = DELETE_CONVERTER.apply(deleteQuery, getParser());
ColumnDeleteQuery query = queryParams.getQuery();
Params params = queryParams.getParams();
getParamsBinder().bind(params, args, method);
return query;
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method shouldDeleteColumnFamily.
@Test
public void shouldDeleteColumnFamily() {
entityManager.insert(getColumnFamily());
ColumnEntity.of(Constants.COLUMN_FAMILY, singletonList(Columns.of("id", 10L)));
ColumnQuery query = select().from(Constants.COLUMN_FAMILY).where("id").eq(10L).build();
ColumnDeleteQuery deleteQuery = delete().from(Constants.COLUMN_FAMILY).where("id").eq(10L).build();
entityManager.delete(deleteQuery);
List<ColumnEntity> entities = entityManager.cql("select * from newKeySpace.newColumnFamily where id=10;").collect(toList());
assertTrue(entities.isEmpty());
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana-driver by eclipse.
the class HBaseColumnFamilyManagerTest method shouldDeleteEntities.
@Test
public void shouldDeleteEntities() {
columnFamilyManager.insert(createEntity());
columnFamilyManager.insert(createEntity2());
ColumnQuery query = select().from(FAMILY).where(ID_FIELD).eq("otaviojava").or(ID_FIELD).eq("poliana").build();
ColumnDeleteQuery deleteQuery = delete().from(FAMILY).where(ID_FIELD).eq("otaviojava").or(ID_FIELD).eq("poliana").build();
columnFamilyManager.delete(deleteQuery);
List<ColumnEntity> entities = columnFamilyManager.select(query).collect(Collectors.toList());
assertTrue(entities.isEmpty());
}
Aggregations