OPENJPA-1917: Cache column alias.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1055524 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Richard G. Curtis 2011-01-05 16:58:33 +00:00
parent 933da55ce5
commit 0549627bd2
1 changed files with 17 additions and 3 deletions

View File

@ -2319,6 +2319,7 @@ public class SelectImpl
implements PathJoins {
private SelectImpl _sel = null;
private Map<Column, Object> cachedColumnAlias_ = null;
// position in selected columns list where we expect the next load
private int _pos = 0;
@ -2399,8 +2400,15 @@ public class SelectImpl
// we key directly on objs and join-less cols, or on the alias
// for cols with joins
PathJoins pj = getJoins(joins);
if (pj != null && pj.path() != null)
obj = getColumnAlias((Column) obj, pj);
if (pj != null && pj.path() != null) {
Object columnAlias = getColumnAlias((Column) obj, pj);
if (joins == null) {
if (cachedColumnAlias_ == null)
cachedColumnAlias_ = new HashMap<Column, Object>();
cachedColumnAlias_.put((Column) obj, columnAlias);
}
return columnAlias != null && _sel._selects.contains(columnAlias);
}
return obj != null && _sel._selects.contains(obj);
}
@ -2449,7 +2457,13 @@ public class SelectImpl
if (pj != null && pj.path() != null) {
Column col = (Column) obj;
pk = (col.isPrimaryKey()) ? Boolean.TRUE : Boolean.FALSE;
obj = getColumnAlias(col, pj);
if (joins == null && cachedColumnAlias_ != null) {
obj = cachedColumnAlias_.get(col);
if (obj == null)
obj = getColumnAlias(col, pj);
} else {
obj = getColumnAlias(col, pj);
}
if (obj == null)
throw new SQLException(col.getTable() + ": "
+ pj.path() + " (" + _sel._aliases + ")");