Connection connection = null;
Statement statement = null;
ResultSet set = null;
try {
connection = dataSource.getConnection();
QuerySnapshot snapshot = builder.build();
if (builder.getParameters().size() > 0) {
PreparedStatement prepared = connection.prepareStatement(snapshot.getQueryString());
int index = 1;
for (IQueryFragmentCriteriaParameter parameter : snapshot.getArguments()) {
for (String name : parameter.getNamedParameters()) {
prepared.setObject(index++, builder.getParameters().get(name));
}
}
return translate( prepared.executeQuery() );
} else {
statement = connection.createStatement();
return translate( statement.executeQuery( snapshot.getQueryString() ) );
}
} catch (SQLException e) {
throw ThrowableManagerRegistry.caught(e);
} finally {
if (set != null) try { set.close(); } catch (SQLException e) {