use of jakarta.nosql.mapping.DynamicQueryException in project jnosql-diana by eclipse.
the class AbstractGraphRepositoryProxy method converter.
private Object converter(Method method, Class<?> typeClass, Supplier<Stream<?>> querySupplier, Object[] args) {
Supplier<Optional<?>> singleSupplier = DynamicReturn.toSingleResult(method).apply(querySupplier);
Function<Pagination, Page<?>> pageFunction = p -> {
throw new DynamicQueryException("Graph database repository does not support Page as return Type");
};
DynamicReturn<?> dynamicReturn = DynamicReturn.builder().withClassSource(typeClass).withMethodSource(method).withResult(querySupplier).withSingleResult(singleSupplier).withPagination(DynamicReturn.findPagination(args)).withStreamPagination(p -> querySupplier.get()).withSingleResultPagination(p -> singleSupplier.get()).withPage(pageFunction).build();
return dynamicReturn.execute();
}
use of jakarta.nosql.mapping.DynamicQueryException in project jnosql-diana by eclipse.
the class AbstractReactiveKeyValueRepositoryProxy method invoke.
@Override
public Object invoke(Object instance, Method method, Object[] args) throws Throwable {
RepositoryType type = ReactiveRepositoryType.of(method);
switch(type) {
case DEFAULT:
return method.invoke(getReactiveRepository(), args);
case OBJECT_METHOD:
return method.invoke(this, args);
case JNOSQL_QUERY:
Class<?> typeClass = getEntityClass();
DynamicQueryMethodReturn methodReturn = DynamicQueryMethodReturn.builder().withArgs(args).withMethod(method).withTypeClass(typeClass).withPrepareConverter(q -> getTemplate().prepare(q, typeClass)).withQueryConverter(q -> getTemplate().query(q, typeClass)).build();
return methodReturn.execute();
default:
throw new DynamicQueryException("Key Value repository does not support query method");
}
}
use of jakarta.nosql.mapping.DynamicQueryException in project jnosql-diana by eclipse.
the class AbstractKeyValueRepositoryProxy method invoke.
@Override
public Object invoke(Object instance, Method method, Object[] args) throws Throwable {
RepositoryType type = RepositoryType.of(method);
switch(type) {
case DEFAULT:
return method.invoke(getRepository(), args);
case OBJECT_METHOD:
return method.invoke(this, args);
case JNOSQL_QUERY:
Class<?> typeClass = getEntityClass();
DynamicQueryMethodReturn methodReturn = DynamicQueryMethodReturn.builder().withArgs(args).withMethod(method).withTypeClass(typeClass).withPrepareConverter(q -> getTemplate().prepare(q, typeClass)).withQueryConverter(q -> getTemplate().query(q, typeClass)).build();
return methodReturn.execute();
default:
throw new DynamicQueryException("Key Value repository does not support query method");
}
}
Aggregations