Make lookups by column name case insensitive. Also, hide the
column to property map from the outside world so nobody can do a case sensitive lookup by fault.
This commit is contained in:
parent
b294dabc90
commit
12e5fd0846
1 changed files with 10 additions and 9 deletions
|
@ -8,6 +8,7 @@ import helma.util.Updatable;
|
||||||
import helma.util.SystemProperties;
|
import helma.util.SystemProperties;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import com.workingdogs.village.*;
|
import com.workingdogs.village.*;
|
||||||
|
@ -95,7 +96,7 @@ public class DbMapping implements Updatable {
|
||||||
parent = null;
|
parent = null;
|
||||||
// subnodes = null;
|
// subnodes = null;
|
||||||
// properties = null;
|
// properties = null;
|
||||||
idField = "id";
|
idField = "ID";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,7 +113,7 @@ public class DbMapping implements Updatable {
|
||||||
parent = null;
|
parent = null;
|
||||||
// subnodes = null;
|
// subnodes = null;
|
||||||
// properties = null;
|
// properties = null;
|
||||||
idField = "id";
|
idField = "ID";
|
||||||
|
|
||||||
this.props = props;
|
this.props = props;
|
||||||
update ();
|
update ();
|
||||||
|
@ -160,7 +161,7 @@ public class DbMapping implements Updatable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// id field must not be null, default is "id"
|
// id field must not be null, default is "id"
|
||||||
idField = props.getProperty ("_id", "id");
|
idField = props.getProperty ("_id", "ID");
|
||||||
|
|
||||||
nameField = props.getProperty ("_name");
|
nameField = props.getProperty ("_name");
|
||||||
|
|
||||||
|
@ -212,7 +213,7 @@ public class DbMapping implements Updatable {
|
||||||
if (rel.columnName != null &&
|
if (rel.columnName != null &&
|
||||||
(rel.reftype == Relation.PRIMITIVE ||
|
(rel.reftype == Relation.PRIMITIVE ||
|
||||||
rel.reftype == Relation.REFERENCE))
|
rel.reftype == Relation.REFERENCE))
|
||||||
d2p.put (rel.columnName, rel);
|
d2p.put (rel.columnName.toUpperCase (), rel);
|
||||||
// app.logEvent ("Mapping "+propName+" -> "+dbField);
|
// app.logEvent ("Mapping "+propName+" -> "+dbField);
|
||||||
}
|
}
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
|
@ -396,7 +397,7 @@ public class DbMapping implements Updatable {
|
||||||
return null;
|
return null;
|
||||||
if (table == null && parentMapping != null)
|
if (table == null && parentMapping != null)
|
||||||
return parentMapping.columnNameToProperty (columnName);
|
return parentMapping.columnNameToProperty (columnName);
|
||||||
Relation rel = (Relation) db2prop.get (columnName);
|
Relation rel = (Relation) db2prop.get (columnName.toUpperCase ());
|
||||||
if (rel != null && (rel.reftype == Relation.PRIMITIVE || rel.reftype == Relation.REFERENCE))
|
if (rel != null && (rel.reftype == Relation.PRIMITIVE || rel.reftype == Relation.REFERENCE))
|
||||||
return rel.propName;
|
return rel.propName;
|
||||||
return null;
|
return null;
|
||||||
|
@ -424,7 +425,7 @@ public class DbMapping implements Updatable {
|
||||||
return null;
|
return null;
|
||||||
if (table == null && parentMapping != null)
|
if (table == null && parentMapping != null)
|
||||||
return parentMapping.columnNameToRelation (columnName);
|
return parentMapping.columnNameToRelation (columnName);
|
||||||
return (Relation) db2prop.get (columnName);
|
return (Relation) db2prop.get (columnName.toUpperCase ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -670,10 +671,10 @@ public class DbMapping implements Updatable {
|
||||||
return prop2db;
|
return prop2db;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap getDB2Prop () {
|
public Iterator getDBPropertyIterator () {
|
||||||
if (table == null && parentMapping != null)
|
if (table == null && parentMapping != null)
|
||||||
return parentMapping.getDB2Prop ();
|
return parentMapping.getDBPropertyIterator ();
|
||||||
return db2prop;
|
return db2prop.values ().iterator ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue