pMethod.addTry();
int paramNum = 0;
for (Iterator iter = pColumnSet.getColumns(); iter.hasNext(); ) {
Object v = new Object[]{pValues, "[", Integer.toString(paramNum), "]"};
Column column = (Column) iter.next();
setPreparedStatementValue(pMethod, column, stmt, Integer.toString(++paramNum), v);
}
LocalJavaField rs = pMethod.newJavaField(ResultSet.class, "rs");
rs.addLine(stmt, ".executeQuery()");
LocalJavaField isRsClosed = pMethod.newJavaField(boolean.class);
isRsClosed.addLine("false");
LocalJavaField result;
if (pReturnValue) {
result = pMethod.newJavaField(Object[].class, "result");
result.addLine("null");
} else {
result = null;
}
pMethod.addTry();
pMethod.addWhile(rs, ".next()");
if (result != null) {
pMethod.addIf(result, " != null");
pMethod.addThrowNew(IllegalStateException.class,
JavaSource.getQuoted("Expected a single row only."));
pMethod.addEndIf();
}
int resultColumnSize = 0;
for (Iterator iter = table.getColumns(); iter.hasNext(); iter.next()) {
++resultColumnSize;
}
LocalJavaField row = pMethod.newJavaField(Object[].class, "row");
row.addLine("new ", Object.class, "[" + resultColumnSize + "];");
int resultColumnNum = 0;
for (Iterator iter = table.getColumns(); iter.hasNext(); ) {
Column column = (Column) iter.next();
setResultSetValue(pMethod, column, rs, resultColumnNum++, row);
}
pMethod.addLine(((result == null) ? "" : "result = "),
getInsertRowMethodName(pTableInfo), "(", pConn, ", ", pMap, ", ",