import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
+import java.util.StringJoiner;
public class MSqlTable extends MObject {
}
fields.delete(fields.length() - 2, fields.length());
s.delete(s.length() - 2, s.length());
+ //
return this.getDatabaseConnection().executePreparedStatement(" INSERT INTO \"" + this.getTable() + "\""
+ " (" + fields + ")"
+ " VALUES (" + s + ")",
}
s.delete(s.length() - 2, s.length());
p.add(id);
+ //
return this.getDatabaseConnection().executePreparedStatement(" UPDATE \"" + this.getTable() + "\""
+ " SET " + s
+ " WHERE (\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" = ?)",
//
LinkedList<Object> p = new LinkedList<Object>();
p.add(id);
+ //
return this.getDatabaseConnection().executePreparedStatement(" SELECT *"
+ " FROM \"" + this.getTable() + "\""
+ " WHERE (\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" = ?)",
//
LinkedList<Object> p = new LinkedList<Object>();
p.add(id);
+ //
return this.getDatabaseConnection().executePreparedStatement(" DELETE FROM \"" + this.getTable() + "\""
+ " WHERE (\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" = ?)",
p);
throw new IllegalArgumentException("Invalid 'idSet': null.");
}
//
- StringBuilder whereClause = new StringBuilder("(0)");
- LinkedList<Object> p = new LinkedList<Object>();
- for (Object id: idSet) {
- whereClause.append(" OR (\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" = ?)");
- p.add(id);
+ String whereClause = null;
+ LinkedList<Object> p = null;
+ if (0 == idSet.size()) {
+ whereClause = "0";
+ }
+ else {
+ StringJoiner s = new StringJoiner(", ");
+ p = new LinkedList<Object>();
+ for (Object id: idSet) {
+ s.add("?");
+ p.add(id);
+ }
+ whereClause = "\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" IN (" + s.toString() + ")";
}
+ //
return this.getDatabaseConnection().executePreparedStatement(" DELETE FROM \"" + this.getTable() + "\""
+ " WHERE (" + whereClause + ")",
p);