use of org.eclipse.jnosql.mapping.reflection.ClassMapping in project jnosql-diana by eclipse.
the class AbstractDocumentTemplate 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());
DocumentDeleteQuery query = DocumentDeleteQuery.delete().from(classMapping.getName()).where(idField.getName()).eq(value).build();
delete(query);
}
use of org.eclipse.jnosql.mapping.reflection.ClassMapping in project jnosql-diana by eclipse.
the class DefaultDocumentQueryMapper method deleteFrom.
@Override
public <T> DocumentMapperDeleteFrom deleteFrom(Class<T> entityClass) {
requireNonNull(entityClass, "entity is required");
ClassMapping mapping = mappings.get().get(entityClass);
return new DefaultDocumentMapperDeleteBuilder(mapping, converters.get());
}
use of org.eclipse.jnosql.mapping.reflection.ClassMapping in project jnosql-diana by eclipse.
the class SelectQueryConverter method apply.
@Override
public Stream<Vertex> apply(GraphQueryMethod graphQuery, Object[] params) {
SelectMethodProvider selectMethodFactory = SelectMethodProvider.get();
SelectQuery query = selectMethodFactory.apply(graphQuery.getMethod(), graphQuery.getEntityName());
ClassMapping mapping = graphQuery.getMapping();
GraphTraversal<Vertex, Vertex> traversal = getGraphTraversal(graphQuery, query::getWhere, mapping);
query.getOrderBy().forEach(getSort(traversal, mapping));
setSort(params, traversal);
setPagination(params, traversal, query);
traversal.hasLabel(mapping.getName());
return traversal.toStream();
}
use of org.eclipse.jnosql.mapping.reflection.ClassMapping in project jnosql-diana by eclipse.
the class DeleteQueryConverter method apply.
@Override
public List<Vertex> apply(GraphQueryMethod graphQuery) {
DeleteMethodProvider provider = DeleteMethodProvider.get();
DeleteQuery deleteQuery = provider.apply(graphQuery.getMethod(), graphQuery.getEntityName());
ClassMapping mapping = graphQuery.getMapping();
GraphTraversal<Vertex, Vertex> traversal = getGraphTraversal(graphQuery, deleteQuery::getWhere, mapping);
traversal.hasLabel(mapping.getName());
return traversal.toList();
}
use of org.eclipse.jnosql.mapping.reflection.ClassMapping in project jnosql-diana by eclipse.
the class AbstractColumnTemplate method count.
@Override
public <T> long count(Class<T> entityClass) {
requireNonNull(entityClass, "entity class is required");
ClassMapping classMapping = getClassMappings().get(entityClass);
return getManager().count(classMapping.getName());
}
Aggregations