use of org.eclipse.jnosql.mapping.query.RepositoryType in project jnosql-diana by eclipse.
the class ReactiveRepositoryTypeTest method shouldReturnUnknown.
@Test
public void shouldReturnUnknown() {
final Method method = Stream.of(Repository.class.getDeclaredMethods()).filter(m -> "save".equals(m.getName())).findFirst().get();
final RepositoryType type = ReactiveRepositoryType.of(method);
Assertions.assertEquals(RepositoryType.UNKNOWN, type);
}
use of org.eclipse.jnosql.mapping.query.RepositoryType 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");
}
}
use of org.eclipse.jnosql.mapping.query.RepositoryType in project jnosql-diana by eclipse.
the class AbstractColumnRepositoryProxy method invoke.
@Override
public Object invoke(Object instance, Method method, Object[] args) throws Throwable {
RepositoryType type = RepositoryType.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 = ColumnQuery.select().from(getClassMapping().getName()).build();
return executeQuery(method, args, typeClass, getQuerySorts(args, queryFindAll));
case DELETE_BY:
ColumnDeleteQuery deleteQuery = getDeleteQuery(method, args);
getTemplate().delete(deleteQuery);
return Void.class;
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;
}
}
Aggregations