* Implement mechanism to register parent nodes with changed child nodes with the transactor.
When finishing the transaction, the transactor will call setLastSubnodeChange() on the parent nodes. This is necessary because the lastSubnodeChange flag should only be set after child node changes have been committed to the database. (Fixes bug 285 http://helma.org/bugs/show_bug.cgi?id=285 ) * Changed the way select statements are built: Use tablename.* rather than * to prevent columns from additionalTables are fetched unnecessarily. * Code cleanup everywhere, mostly in Transactor.java, Relation.java and NodeManager.java
This commit is contained in:
parent
507949310c
commit
6f8c9b9837
1 changed files with 23 additions and 23 deletions
|
@ -824,13 +824,13 @@ public final class DbMapping implements Updatable {
|
|||
// and build a string of column names.
|
||||
Connection con = getConnection();
|
||||
Statement stmt = con.createStatement();
|
||||
String t = getTableName();
|
||||
String table = getTableName();
|
||||
|
||||
if (t == null) {
|
||||
if (table == null) {
|
||||
throw new SQLException("Table name is null in getColumns() for " + this);
|
||||
}
|
||||
|
||||
ResultSet rs = stmt.executeQuery(new StringBuffer("SELECT * FROM ").append(t)
|
||||
ResultSet rs = stmt.executeQuery(new StringBuffer("SELECT * FROM ").append(table)
|
||||
.append(" WHERE 1 = 0")
|
||||
.toString());
|
||||
|
||||
|
@ -921,36 +921,35 @@ public final class DbMapping implements Updatable {
|
|||
|
||||
StringBuffer s = new StringBuffer("SELECT ");
|
||||
|
||||
/* DbColumn[] cols = columns;
|
||||
String table = getTableName();
|
||||
|
||||
if (cols == null) {
|
||||
cols = getColumns();
|
||||
}
|
||||
|
||||
for (int i = 0; i < cols.length; i++) {
|
||||
s.append(cols[i].getName());
|
||||
if (i < cols.length-1) {
|
||||
s.append(',');
|
||||
}
|
||||
}
|
||||
// all columns from the main table
|
||||
s.append(table);
|
||||
s.append(".*");
|
||||
|
||||
for (int i = 0; i < joins.length; i++) {
|
||||
} */
|
||||
|
||||
s.append ("*");
|
||||
if (!joins[i].otherType.isRelational()) {
|
||||
continue;
|
||||
}
|
||||
s.append(", ");
|
||||
s.append(Relation.JOIN_PREFIX);
|
||||
s.append(joins[i].propName);
|
||||
s.append(".*");
|
||||
}
|
||||
|
||||
s.append(" FROM ");
|
||||
|
||||
s.append(getTableName());
|
||||
s.append(table);
|
||||
s.append(" ");
|
||||
|
||||
for (int i = 0; i < joins.length; i++) {
|
||||
if (!joins[i].otherType.isRelational()) {
|
||||
continue;
|
||||
}
|
||||
s.append("LEFT JOIN ");
|
||||
s.append("LEFT OUTER JOIN ");
|
||||
s.append(joins[i].otherType.getTableName());
|
||||
s.append(" AS _HLM_");
|
||||
s.append(" AS ");
|
||||
s.append(Relation.JOIN_PREFIX);
|
||||
s.append(joins[i].propName);
|
||||
s.append(" ON ");
|
||||
joins[i].renderJoinConstraints(s);
|
||||
|
@ -1080,11 +1079,12 @@ public final class DbMapping implements Updatable {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public void notifyDataChange() {
|
||||
lastDataChange = System.currentTimeMillis();
|
||||
public void setLastDataChange(long t) {
|
||||
lastDataChange = t;
|
||||
|
||||
// propagate data change timestamp to parent mapping
|
||||
if ((parentMapping != null) && (dbSource == null)) {
|
||||
parentMapping.notifyDataChange();
|
||||
parentMapping.setLastDataChange(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue