* 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:
parent
d0c7012318
commit
48ed72b6b4
2 changed files with 25 additions and 3 deletions
|
@ -110,6 +110,9 @@ public final class DbMapping implements Updatable {
|
|||
// timestamp of last modification of an object of this type
|
||||
long lastDataChange;
|
||||
|
||||
// evict objects of this type when received via replication
|
||||
private boolean evictOnReplication;
|
||||
|
||||
/**
|
||||
* Create an empty DbMapping
|
||||
*/
|
||||
|
@ -194,6 +197,8 @@ public final class DbMapping implements Updatable {
|
|||
|
||||
String parentSpec = props.getProperty("_parent");
|
||||
|
||||
evictOnReplication = "true".equals(props.getProperty("_evictOnReplication"));
|
||||
|
||||
if (parentSpec != null) {
|
||||
// comma-separated list of properties to be used as parent
|
||||
StringTokenizer st = new StringTokenizer(parentSpec, ",;");
|
||||
|
@ -459,6 +464,14 @@ public final class DbMapping implements Updatable {
|
|||
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.
|
||||
*/
|
||||
|
|
|
@ -507,7 +507,7 @@ public final class NodeManager {
|
|||
String name = columns[i].getName();
|
||||
|
||||
if (((rel != null) && (rel.isPrimitive() || rel.isReference())) ||
|
||||
name.equals(nameField) || name.equals(prototypeField)) {
|
||||
name.equalsIgnoreCase(nameField) || name.equalsIgnoreCase(prototypeField)) {
|
||||
b1.append(", " + columns[i].getName());
|
||||
b2.append(", ?");
|
||||
}
|
||||
|
@ -1967,11 +1967,20 @@ public final class NodeManager {
|
|||
dbm.setLastDataChange(now);
|
||||
}
|
||||
|
||||
n.lastParentSet = -1;
|
||||
n.setDbMapping(dbm);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
for (Enumeration en = delete.elements(); en.hasMoreElements();) {
|
||||
// NOTE: it would be more efficient to transfer just the keys
|
||||
|
|
Loading…
Add table
Reference in a new issue