* Make check for _prototype and _name column case insensitive when inserting relational objects

* Implemented feature to evict certain prototypes from cache when they are received via replication.
   To activate this, add the line
        _evictOnReplication = true
  to the type.property file
This commit is contained in:
hns 2003-11-28 13:53:43 +00:00
parent d0c7012318
commit 48ed72b6b4
2 changed files with 25 additions and 3 deletions

View file

@ -110,6 +110,9 @@ public final class DbMapping implements Updatable {
// timestamp of last modification of an object of this type // timestamp of last modification of an object of this type
long lastDataChange; long lastDataChange;
// evict objects of this type when received via replication
private boolean evictOnReplication;
/** /**
* Create an empty DbMapping * Create an empty DbMapping
*/ */
@ -194,6 +197,8 @@ public final class DbMapping implements Updatable {
String parentSpec = props.getProperty("_parent"); String parentSpec = props.getProperty("_parent");
evictOnReplication = "true".equals(props.getProperty("_evictOnReplication"));
if (parentSpec != null) { if (parentSpec != null) {
// comma-separated list of properties to be used as parent // comma-separated list of properties to be used as parent
StringTokenizer st = new StringTokenizer(parentSpec, ",;"); StringTokenizer st = new StringTokenizer(parentSpec, ",;");
@ -459,6 +464,14 @@ public final class DbMapping implements Updatable {
return protoField; return protoField;
} }
/**
* Should objects of this type be evicted/discarded/reloaded when received via
* cache replication?
*/
public boolean evictOnReplication() {
return evictOnReplication;
}
/** /**
* Translate a database column name to an object property name according to this mapping. * Translate a database column name to an object property name according to this mapping.
*/ */

View file

@ -507,7 +507,7 @@ public final class NodeManager {
String name = columns[i].getName(); String name = columns[i].getName();
if (((rel != null) && (rel.isPrimitive() || rel.isReference())) || if (((rel != null) && (rel.isPrimitive() || rel.isReference())) ||
name.equals(nameField) || name.equals(prototypeField)) { name.equalsIgnoreCase(nameField) || name.equalsIgnoreCase(prototypeField)) {
b1.append(", " + columns[i].getName()); b1.append(", " + columns[i].getName());
b2.append(", ?"); b2.append(", ?");
} }
@ -1967,11 +1967,20 @@ public final class NodeManager {
dbm.setLastDataChange(now); dbm.setLastDataChange(now);
} }
n.lastParentSet = -1;
n.setDbMapping(dbm); n.setDbMapping(dbm);
n.nmgr = safe; n.nmgr = safe;
if (dbm != null && dbm.evictOnReplication()) {
Node oldNode = (Node) cache.get(n.getKey());
if (oldNode != null) {
evictNode(oldNode);
}
} else {
n.lastParentSet = -1;
cache.put(n.getKey(), n); cache.put(n.getKey(), n);
} }
}
for (Enumeration en = delete.elements(); en.hasMoreElements();) { for (Enumeration en = delete.elements(); en.hasMoreElements();) {
// NOTE: it would be more efficient to transfer just the keys // NOTE: it would be more efficient to transfer just the keys