OPENJPA-495 Populate Ordering/ProjectClauses from JPQL parser to be used for merging multiple ordered results

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@612583 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2008-01-16 22:01:42 +00:00
parent 8464ea75f1
commit 240d356314
2 changed files with 6 additions and 1 deletions

View File

@ -722,6 +722,8 @@ public class ExpressionStoreQuery
_inMemOrdering = _parser.eval(_exps[0].orderingClauses, _inMemOrdering = _parser.eval(_exps[0].orderingClauses,
(ExpressionStoreQuery) q, factory, _meta); (ExpressionStoreQuery) q, factory, _meta);
} }
if (_inMemOrdering == null)
_inMemOrdering = _exps[0].ordering;
} }
// use the parsed ordering expression to extract the ordering value // use the parsed ordering expression to extract the ordering value

View File

@ -319,6 +319,7 @@ public class JPQLExpressionBuilder
JPQLNode node = onlyChild(parent); JPQLNode node = onlyChild(parent);
Value proj = getValue(node); Value proj = getValue(node);
exps.projections[i] = proj; exps.projections[i] = proj;
exps.projectionClauses[i] = assemble(node);
exps.projectionAliases[i] = nextAlias(); exps.projectionAliases[i] = nextAlias();
} }
return exp; return exp;
@ -370,10 +371,12 @@ public class JPQLExpressionBuilder
if (orderby != null) { if (orderby != null) {
int ordercount = orderby.getChildCount(); int ordercount = orderby.getChildCount();
exps.ordering = new Value[ordercount]; exps.ordering = new Value[ordercount];
exps.orderingClauses = new String[ordercount];
exps.ascending = new boolean[ordercount]; exps.ascending = new boolean[ordercount];
for (int i = 0; i < ordercount; i++) { for (int i = 0; i < ordercount; i++) {
JPQLNode node = orderby.getChild(i); JPQLNode node = orderby.getChild(i);
exps.ordering[i] = getValue(firstChild(node)); exps.ordering[i] = getValue(firstChild(node));
exps.orderingClauses[i] = assemble(firstChild(node));
// ommission of ASC/DESC token implies ascending // ommission of ASC/DESC token implies ascending
exps.ascending[i] = node.getChildCount() <= 1 || exps.ascending[i] = node.getChildCount() <= 1 ||
lastChild(node).id == JJTASCENDING ? true : false; lastChild(node).id == JJTASCENDING ? true : false;
@ -1374,7 +1377,7 @@ public class JPQLExpressionBuilder
private Value getValue(JPQLNode node, int handleVar) { private Value getValue(JPQLNode node, int handleVar) {
Value val = (Value) eval(node); Value val = (Value) eval(node);
// determind how to evauate a variabe // determined how to evaluate a variable
if (!val.isVariable()) if (!val.isVariable())
return val; return val;
else if (handleVar == VAR_PATH && !(val instanceof Path)) else if (handleVar == VAR_PATH && !(val instanceof Path))