Search in sources :

Example 36 with ColumnDeleteQuery

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());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 37 with ColumnDeleteQuery

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);
}
Also used : ColumnDeleteQueryParams(jakarta.nosql.column.ColumnDeleteQueryParams) Params(jakarta.nosql.Params) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery)

Example 38 with ColumnDeleteQuery

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);
}
Also used : ColumnDeleteQueryParams(jakarta.nosql.column.ColumnDeleteQueryParams) Params(jakarta.nosql.Params) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery)

Example 39 with ColumnDeleteQuery

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());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 40 with ColumnDeleteQuery

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;
    }
}
Also used : DynamicQueryMethodReturn(org.eclipse.jnosql.mapping.repository.DynamicQueryMethodReturn) BaseColumnRepository(org.eclipse.jnosql.mapping.column.query.BaseColumnRepository) RepositoryType(org.eclipse.jnosql.mapping.query.RepositoryType) ReactiveRepositoryType(org.eclipse.jnosql.mapping.reactive.ReactiveRepositoryType) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) ColumnTemplate(jakarta.nosql.mapping.column.ColumnTemplate) ColumnQuery.select(jakarta.nosql.column.ColumnQuery.select) ReactiveRepository(org.eclipse.jnosql.mapping.reactive.ReactiveRepository) ColumnQuery(jakarta.nosql.column.ColumnQuery) DynamicQueryMethodReturn(org.eclipse.jnosql.mapping.repository.DynamicQueryMethodReturn) InvocationHandler(java.lang.reflect.InvocationHandler) ReactiveStreams(org.eclipse.microprofile.reactive.streams.operators.ReactiveStreams) Method(java.lang.reflect.Method) Collections(java.util.Collections) ColumnQuery(jakarta.nosql.column.ColumnQuery) RepositoryType(org.eclipse.jnosql.mapping.query.RepositoryType) ReactiveRepositoryType(org.eclipse.jnosql.mapping.reactive.ReactiveRepositoryType) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery)

Aggregations

ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)70 Test (org.junit.jupiter.api.Test)41 ColumnCondition (jakarta.nosql.column.ColumnCondition)33 Column (jakarta.nosql.column.Column)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 ValueSource (org.junit.jupiter.params.provider.ValueSource)20 Person (jakarta.nosql.tck.entities.Person)12 List (java.util.List)12 ColumnEntity (jakarta.nosql.column.ColumnEntity)6 Params (jakarta.nosql.Params)5 ColumnDeleteQueryParams (jakarta.nosql.column.ColumnDeleteQueryParams)5 ColumnQuery (jakarta.nosql.column.ColumnQuery)5 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)4 ColumnFamilyManager (jakarta.nosql.column.ColumnFamilyManager)3 DeleteQuery (jakarta.nosql.query.DeleteQuery)3 Optional (java.util.Optional)3 QueryException (jakarta.nosql.QueryException)2 ServiceLoaderProvider (jakarta.nosql.ServiceLoaderProvider)2 ColumnObserverParser (jakarta.nosql.column.ColumnObserverParser)2 DeleteQueryConverter (jakarta.nosql.column.DeleteQueryConverter)2