private Object find(final Method method, final Object[] args) { final String methodName = method.getName(); final Class<?> type = getReturnedType(method); final Query query = createFinderQuery(em, methodName, type, args); return getQueryResult(method, query); }
private Class<?> getReturnedType(final Method method) { final String methodName = method.getName(); final Class<?> type; if (returnsTypes.containsKey(methodName)) { type = returnsTypes.get(methodName); } else { type = getGenericType(method.getGenericReturnType()); returnsTypes.put(methodName, type); } return type; }
private <T> Query createFinderQuery(final EntityManager entityManager, final String methodName, final Class<T> entityType, final Object[] args) { final List<String> conditions = parseMethodName(methodName); && isInt(args[args.length - 2].getClass()) && isInt(args[args.length - 1].getClass())) { final int first = (Integer) args[args.length - 2]; final int max = (Integer) args[args.length - 1];
} else if (isInt(args[i].getClass())) { final int next = i + 1; if (args.length == next || !isInt(args[next].getClass())) { throw new IllegalArgumentException("if you provide a firstResult (first int parameter)" + "you should provide a maxResult too"); return getQueryResult(method, query);
private <T> Query createFinderQuery(final EntityManager entityManager, final String methodName, final Class<T> entityType, final Object[] args) { final List<String> conditions = parseMethodName(methodName); && isInt(args[args.length - 2].getClass()) && isInt(args[args.length - 1].getClass())) { final int first = (Integer) args[args.length - 2]; final int max = (Integer) args[args.length - 1];
} else if (isInt(args[i].getClass())) { final int next = i + 1; if (args.length == next || !isInt(args[next].getClass())) { throw new IllegalArgumentException("if you provide a firstResult (first int parameter)" + "you should provide a maxResult too"); return getQueryResult(method, query);
private Object find(final Method method, final Object[] args) { final String methodName = method.getName(); final Class<?> type = getReturnedType(method); final Query query = createFinderQuery(em, methodName, type, args); return getQueryResult(method, query); }
private Class<?> getReturnedType(final Method method) { final String methodName = method.getName(); final Class<?> type; if (returnsTypes.containsKey(methodName)) { type = returnsTypes.get(methodName); } else { type = getGenericType(method.getGenericReturnType()); returnsTypes.put(methodName, type); } return type; }