/** * Get json objects by the specified query. Calling this interface just returns result object list, no pagination info. * * @param query the specified query * @return a list of result json object, returns an empty list if not found * @throws RepositoryException repository exception */ default List<JSONObject> getList(final Query query) throws RepositoryException { final JSONObject result = get(query); return CollectionUtils.jsonArrayToList(result.optJSONArray(Keys.RESULTS)); }
@Override public List<JSONObject> select(final String statement, final Object... params) throws RepositoryException { JSONArray jsonResults; final Connection connection = getConnection(); try { if (null == params || 0 == params.length) { jsonResults = JdbcUtil.queryJsonArray(statement, Collections.emptyList(), connection, getName(), debug); } else { jsonResults = JdbcUtil.queryJsonArray(statement, Arrays.asList(params), connection, getName(), debug); } return CollectionUtils.jsonArrayToList(jsonResults); } catch (final Exception e) { LOGGER.log(Level.ERROR, "Select failed", e); throw new RepositoryException(e); } }
/** * Gets json objects by the specified query. Calling this interface just returns result object list, no pagination info. * * @param query the specified query * @return a list of result json object, returns an empty list if not found * @throws RepositoryException repository exception */ default List<JSONObject> getList(final Query query) throws RepositoryException { final JSONObject result = get(query); return CollectionUtils.jsonArrayToList(result.optJSONArray(Keys.RESULTS)); }
@Override public List<JSONObject> select(final String statement, final Object... params) throws RepositoryException { JSONArray jsonResults; final Connection connection = getConnection(); try { if (null == params || 0 == params.length) { jsonResults = JdbcUtil.queryJsonArray(statement, Collections.emptyList(), connection, getName(), debug); } else { jsonResults = JdbcUtil.queryJsonArray(statement, Arrays.asList(params), connection, getName(), debug); } return CollectionUtils.jsonArrayToList(jsonResults); } catch (final Exception e) { LOGGER.log(Level.ERROR, "Select failed", e); throw new RepositoryException(e); } }