Currently, all updates and deletes are keyed by primary
key. However, often one wants to update or delete a
row based on some other column. I propose adding
extra delete and update methods to the Driver class
which take an extra string parameter which is the
column to select on:
public int delete(Data data, String keyColumn) throws
SQLException
public int update(Data data, String keyColumn) throws
SQLException
Along with that, an extra getKeyConditions method
should be generated in generated classes:
public String getKeyConditions(String column) {
if ("Column1".equals(column)) {
return "Column1 = " + _Column1;
else if ("Column2".equals(column)) {
return "Column2 = " + _Column2;
} ...
...
}
If I have time I may make this patch.
Logged In: YES
user_id=1290
I should add, that columns could easily be specified by
something more strict typed like numeral values by simply
auto-generating column constants:
static final int COL_COLUMN1 = 0;
static final int COL_COLUMN2 = 1;
static final int COL_COLUMN3 = 2;
public String getKeyConditions(int col) {
switch (col) {
case COL_COLUMN1: return "Column1 = " + _Column1;
break;
case COL_COLUMN2: return "Column2 = " + _Column2;
break;
...
}
}
Hard coded column name literals of course could also easily
be replaced by auto-generating an array of literal strings to
match the column constants:
static final String[] COLUMN_NAMES = new String
[column_count];
static {
COLUMN_NAMES[COL_COLUMN1] = "Column1";
COLUMN_NAMES[COL_COLUMN2] = "Column2";
...
}
case COL_COLUMN1:
return COLUMN_NAMES[COL_COLUMN1] + " = " +
_Column1;