use of org.jnosql.diana.api.column.ColumnDeleteQuery in project jnosql-artemis by eclipse.
the class AbstractColumnRepositoryAsyncProxy method invoke.
@Override
public Object invoke(Object instance, Method method, Object[] args) throws Throwable {
String methodName = method.getName();
ColumnRepositoryType type = ColumnRepositoryType.of(method, args);
switch(type) {
case DEFAULT:
return method.invoke(getRepository(), args);
case FIND_BY:
ColumnQuery query = getQueryParser().parse(methodName, args, getClassRepresentation(), getConverters());
return executeQuery(getCallBack(args), query);
case FIND_ALL:
return executeQuery(getCallBack(args), select().from(getClassRepresentation().getName()).build());
case DELETE_BY:
ColumnDeleteQuery deleteQuery = getDeleteParser().parse(methodName, args, getClassRepresentation(), getConverters());
return executeDelete(getCallBack(args), deleteQuery);
case QUERY:
ColumnQuery columnQuery = ColumnRepositoryType.getQuery(args).get();
return executeQuery(getCallBack(args), columnQuery);
case QUERY_DELETE:
return executeDelete(args, ColumnRepositoryType.getDeleteQuery(args).get());
case OBJECT_METHOD:
return method.invoke(this, args);
default:
return Void.class;
}
}
use of org.jnosql.diana.api.column.ColumnDeleteQuery in project jnosql-artemis by eclipse.
the class AbstractColumnRepositoryProxy method invoke.
@Override
public Object invoke(Object instance, Method method, Object[] args) throws Throwable {
String methodName = method.getName();
ColumnRepositoryType type = ColumnRepositoryType.of(method, args);
Class<?> typeClass = getClassRepresentation().getClassInstance();
switch(type) {
case DEFAULT:
return method.invoke(getRepository(), args);
case FIND_BY:
ColumnQuery query = getQueryParser().parse(methodName, args, getClassRepresentation(), getConverters());
return returnObject(query, getTemplate(), typeClass, method);
case FIND_ALL:
return returnObject(select().from(getClassRepresentation().getName()).build(), getTemplate(), typeClass, method);
case DELETE_BY:
ColumnDeleteQuery deleteQuery = getDeleteParser().parse(methodName, args, getClassRepresentation(), getConverters());
getTemplate().delete(deleteQuery);
return Void.class;
case QUERY:
ColumnQuery columnQuery = getQuery(args).get();
return returnObject(columnQuery, getTemplate(), typeClass, method);
case QUERY_DELETE:
ColumnDeleteQuery columnDeleteQuery = getDeleteQuery(args).get();
getTemplate().delete(columnDeleteQuery);
return Void.class;
case OBJECT_METHOD:
return method.invoke(this, args);
default:
return Void.class;
}
}
use of org.jnosql.diana.api.column.ColumnDeleteQuery in project jnosql-artemis by eclipse.
the class AbstractColumnTemplate method delete.
@Override
public <T, ID> void delete(Class<T> entityClass, ID id) {
requireNonNull(entityClass, "entityClass is required");
requireNonNull(id, "id is required");
ClassRepresentation classRepresentation = getClassRepresentations().get(entityClass);
FieldRepresentation idField = classRepresentation.getId().orElseThrow(() -> IdNotFoundException.newInstance(entityClass));
Object value = ConverterUtil.getValue(id, classRepresentation, idField.getFieldName(), getConverters());
ColumnDeleteQuery query = ColumnQueryBuilder.delete().from(classRepresentation.getName()).where(idField.getName()).eq(value).build();
getManager().delete(query);
}
use of org.jnosql.diana.api.column.ColumnDeleteQuery in project jnosql-artemis by eclipse.
the class AbstractColumnTemplateAsync method delete.
@Override
public <T, ID> void delete(Class<T> entityClass, ID id) {
requireNonNull(entityClass, "entityClass is required");
requireNonNull(id, "id is required");
ColumnDeleteQuery query = getDeleteQuery(entityClass, id);
delete(query);
}
use of org.jnosql.diana.api.column.ColumnDeleteQuery in project jnosql-artemis by eclipse.
the class AbstractColumnTemplateAsync method delete.
@Override
public <T, ID> void delete(Class<T> entityClass, ID id, Consumer<Void> callBack) {
requireNonNull(entityClass, "entityClass is required");
requireNonNull(id, "id is required");
requireNonNull(callBack, "callBack is required");
ColumnDeleteQuery query = getDeleteQuery(entityClass, id);
delete(query, callBack);
}
Aggregations