use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana-driver by eclipse.
the class HBaseColumnFamilyManagerTest method shouldDeleteEntity.
@Test
public void shouldDeleteEntity() {
columnFamilyManager.insert(createEntity());
ColumnQuery query = select().from(FAMILY).where(ID_FIELD).eq("otaviojava").build();
ColumnDeleteQuery deleteQuery = delete().from(FAMILY).where(ID_FIELD).eq("otaviojava").build();
columnFamilyManager.delete(deleteQuery);
List<ColumnEntity> entities = columnFamilyManager.select(query).collect(Collectors.toList());
assertTrue(entities.isEmpty());
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParser method prepare.
ColumnPreparedStatement prepare(String query, ColumnFamilyManager manager, ColumnObserverParser observer) {
Params params = Params.newParams();
ColumnDeleteQuery columnDeleteQuery = getQuery(query, params, observer);
return DefaultColumnPreparedStatement.delete(columnDeleteQuery, params, query, manager);
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParser method apply.
@Override
public ColumnDeleteQueryParams apply(DeleteQuery deleteQuery, ColumnObserverParser columnObserverParser) {
requireNonNull(deleteQuery, "deleteQuery is required");
requireNonNull(columnObserverParser, "columnObserverParser is required");
Params params = Params.newParams();
ColumnDeleteQuery query = getQuery(params, columnObserverParser, deleteQuery);
return new DefaultColumnDeleteQueryParams(query, params);
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method shouldDeleteColumnFamilyWithConsistencyLevel.
@Test
public void shouldDeleteColumnFamilyWithConsistencyLevel() {
entityManager.insert(getColumnFamily());
ColumnEntity.of(Constants.COLUMN_FAMILY, singletonList(Columns.of("id", 10L)));
ColumnDeleteQuery deleteQuery = delete().from(Constants.COLUMN_FAMILY).where("id").eq(10L).build();
entityManager.delete(deleteQuery, CONSISTENCY_LEVEL);
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 by eclipse.
the class AbstractReactiveColumnRepositoryProxy method invoke.
@Override
public Object invoke(Object instance, Method method, Object[] args) throws Throwable {
RepositoryType type = ReactiveRepositoryType.of(method);
Class<?> typeClass = getClassMapping().getClassInstance();
switch(type) {
case DEFAULT:
return method.invoke(getRepository(), args);
case FIND_BY:
ColumnQuery query = getQuery(method, args);
return executeQuery(method, args, typeClass, query);
case FIND_ALL:
ColumnQuery queryFindAll = select().from(getClassMapping().getName()).build();
return executeQuery(method, args, typeClass, getQuerySorts(args, queryFindAll));
case DELETE_BY:
ColumnDeleteQuery columnDeleteQuery = getDeleteQuery(method, args);
Iterable<Void> iterable = () -> {
getTemplate().delete(columnDeleteQuery);
return Collections.emptyIterator();
};
return ReactiveStreams.fromIterable(iterable).buildRs();
case OBJECT_METHOD:
return method.invoke(this, args);
case JNOSQL_QUERY:
DynamicQueryMethodReturn methodReturn = DynamicQueryMethodReturn.builder().withArgs(args).withMethod(method).withTypeClass(typeClass).withPrepareConverter(q -> getTemplate().prepare(q)).withQueryConverter(q -> getTemplate().query(q)).build();
return methodReturn.execute();
default:
return Void.class;
}
}
Aggregations