use of org.jnosql.artemis.reflection.ClassRepresentation in project jnosql-artemis by eclipse.
the class DefaultColumnQueryMapperBuilder method deleteFrom.
@Override
public <T> ColumnDeleteFrom deleteFrom(Class<T> entityClass) {
requireNonNull(entityClass, "entity is required");
ClassRepresentation representation = classRepresentations.get().get(entityClass);
return new DefaultColumnMapperDeleteBuilder(representation, converters.get());
}
use of org.jnosql.artemis.reflection.ClassRepresentation in project jnosql-artemis by eclipse.
the class DefaultColumnQueryMapperBuilder method selectFrom.
@Override
public <T> ColumnFrom selectFrom(Class<T> entityClass) {
requireNonNull(entityClass, "entity is required");
ClassRepresentation representation = classRepresentations.get().get(entityClass);
return new DefaultColumnMapperSelectBuilder(representation, converters.get());
}
use of org.jnosql.artemis.reflection.ClassRepresentation in project jnosql-artemis by eclipse.
the class AbstractDocumentEntityConverter method toEntity.
@SuppressWarnings("unchecked")
@Override
public <T> T toEntity(DocumentEntity entity) {
requireNonNull(entity, "entity is required");
ClassRepresentation representation = getClassRepresentations().findByName(entity.getName());
T instance = getReflections().newInstance(representation.getConstructor());
return convertEntity(entity.getDocuments(), representation, instance);
}
use of org.jnosql.artemis.reflection.ClassRepresentation in project jnosql-artemis by eclipse.
the class AbstractDocumentTemplate 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());
DocumentDeleteQuery query = DocumentQueryBuilder.delete().from(classRepresentation.getName()).where(idField.getName()).eq(value).build();
delete(query);
}
use of org.jnosql.artemis.reflection.ClassRepresentation in project jnosql-artemis by eclipse.
the class AbstractDocumentTemplateAsync method find.
@Override
public <T, ID> void find(Class<T> entityClass, ID id, Consumer<Optional<T>> callBack) {
requireNonNull(entityClass, "entityClass is required");
requireNonNull(id, "id is required");
requireNonNull(callBack, "callBack is required");
ClassRepresentation classRepresentation = getClassRepresentations().get(entityClass);
FieldRepresentation idField = classRepresentation.getId().orElseThrow(() -> IdNotFoundException.newInstance(entityClass));
Object value = ConverterUtil.getValue(id, classRepresentation, idField.getFieldName(), getConverters());
DocumentQuery query = DocumentQueryBuilder.select().from(classRepresentation.getName()).where(idField.getName()).eq(value).build();
singleResult(query, callBack);
}
Aggregations