Set<String> tempKeys = new TreeSet<String>(keys);
Iterator<ModelField> nopkIter = modelEntity.getNopksIterator();
while (nopkIter.hasNext()) {
ModelField curField = nopkIter.next();
if (tempKeys.contains(curField.getName())) {
partialFields.add(curField);
tempKeys.remove(curField.getName());
}
}
if (tempKeys.size() > 0) {
throw new GenericModelException("In partialSelect invalid field names specified: " + tempKeys.toString());
}
StringBuilder sqlBuffer = new StringBuilder("SELECT ");
if (partialFields.size() > 0) {
modelEntity.colNameString(partialFields, sqlBuffer, "", ", ", "", datasourceInfo.aliasViews);
} else {
sqlBuffer.append("*");
}
sqlBuffer.append(SqlJdbcUtil.makeFromClause(modelEntity, datasourceInfo));
sqlBuffer.append(SqlJdbcUtil.makeWhereClause(modelEntity, modelEntity.getPkFieldsUnmodifiable(), entity, "AND", datasourceInfo.joinStyle));
SQLProcessor sqlP = new SQLProcessor(helperInfo);
try {
sqlP.prepareStatement(sqlBuffer.toString(), true, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
SqlJdbcUtil.setPkValues(sqlP, modelEntity, entity, modelFieldTypeReader);
sqlP.executeQuery();
if (sqlP.next()) {
for (int j = 0; j < partialFields.size(); j++) {
ModelField curField = partialFields.get(j);
SqlJdbcUtil.getValue(sqlP.getResultSet(), j + 1, curField, entity, modelFieldTypeReader);
}
entity.synchronizedWithDatasource();
} else {