mirror of https://github.com/apache/openjpa.git
OPENJPA-1917: Cache column alias.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.1.x@1055527 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
976c19e8d0
commit
03896431a6
|
@ -2319,6 +2319,7 @@ public class SelectImpl
|
||||||
implements PathJoins {
|
implements PathJoins {
|
||||||
|
|
||||||
private SelectImpl _sel = null;
|
private SelectImpl _sel = null;
|
||||||
|
private Map<Column, Object> cachedColumnAlias_ = null;
|
||||||
|
|
||||||
// position in selected columns list where we expect the next load
|
// position in selected columns list where we expect the next load
|
||||||
private int _pos = 0;
|
private int _pos = 0;
|
||||||
|
@ -2399,8 +2400,15 @@ public class SelectImpl
|
||||||
// we key directly on objs and join-less cols, or on the alias
|
// we key directly on objs and join-less cols, or on the alias
|
||||||
// for cols with joins
|
// for cols with joins
|
||||||
PathJoins pj = getJoins(joins);
|
PathJoins pj = getJoins(joins);
|
||||||
if (pj != null && pj.path() != null)
|
if (pj != null && pj.path() != null) {
|
||||||
obj = getColumnAlias((Column) obj, pj);
|
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);
|
return obj != null && _sel._selects.contains(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2449,7 +2457,13 @@ public class SelectImpl
|
||||||
if (pj != null && pj.path() != null) {
|
if (pj != null && pj.path() != null) {
|
||||||
Column col = (Column) obj;
|
Column col = (Column) obj;
|
||||||
pk = (col.isPrimaryKey()) ? Boolean.TRUE : Boolean.FALSE;
|
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)
|
if (obj == null)
|
||||||
throw new SQLException(col.getTable() + ": "
|
throw new SQLException(col.getTable() + ": "
|
||||||
+ pj.path() + " (" + _sel._aliases + ")");
|
+ pj.path() + " (" + _sel._aliases + ")");
|
||||||
|
|
Loading…
Reference in New Issue