public <T> List<T> executeWithKeys(Class<T> type) { return executeWithKeys(type, null); }
/** * Execute the clause and return the generated key with the type of the given path. * If no rows were created, or the referenced column is not a generated key, null is returned. * Otherwise, the key of the first row is returned. * * @param <T> * @param path * @return */ @SuppressWarnings("unchecked") public <T> List<T> executeWithKeys(Path<T> path) { return executeWithKeys((Class<T>)path.getType(), path); }
private <T> T executeWithKey(Class<T> type, @Nullable Path<T> path) { ResultSet rs = executeWithKeys(); try{ if (rs.next()) { return configuration.get(rs, path, 1, type); } else { return null; } } catch (SQLException e) { throw configuration.translate(e); }finally{ close(rs); } }
private <T> List<T> executeWithKeys(Class<T> type, @Nullable Path<T> path) { ResultSet rs = null; try{ rs = executeWithKeys(); List<T> rv = new ArrayList<T>(); while (rs.next()) { rv.add(configuration.get(rs, path, 1, type)); } return rv; } catch (SQLException e) { throw configuration.translate(e); }finally { if (rs != null) { close(rs); } reset(); } }