}
}
+ public Row selectExactlyOne(Connection con, Column[] columns, Table[] tables, Condition[] conditions)
+ throws SQLException
+ {
+ Sort[] sorts = new Sort[0];
+ int limit = 2;
+ List<Row> rows = select(con, columns, tables, conditions, sorts, limit);
+ if (rows.size() < 1) {
+ throw new SQLException("Expected one result, but found none: ", selectSql(columns, tables, conditions, sorts, limit));
+ }
+ if (rows.size() > 1) {
+ throw new SQLException("Expected one result, but found more than one: " + selectSql(columns, tables, conditions, sorts, limit));
+ }
+
+ return rows.get(0);
+ }
+
public List<Row> select(Connection con, Column[] columns, Table[] tables, Condition[] conditions)
throws SQLException
{
int count = 0;
int pendingValues = 0;
+ assert( isValidInsert(table, values));
+
String sql = insertSql(table);
try (PreparedStatement ps = con.prepareStatement(sql))
}
abstract protected String nextValSql(Sequence seq);
+
+ boolean isValidInsert(Table table, Object[][] values)
+ {
+ if (null == table) return false;
+ if (null == values) return false;
+
+ for (Object[] rowValues : values) {
+ if (rowValues.length != table.getNumColumns()) {
+ return false;
+ }
+ for (int idx = 0; idx < rowValues.length; ++idx) {
+
+ }
+ }
+
+ return true;
+ }
}