openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "wilesun (JIRA)" <j...@apache.org>
Subject [jira] Created: (OPENJPA-690) JPQL select express support alias
Date Sat, 09 Aug 2008 11:56:44 GMT
JPQL select express support alias
---------------------------------

                 Key: OPENJPA-690
                 URL: https://issues.apache.org/jira/browse/OPENJPA-690
             Project: OpenJPA
          Issue Type: Bug
          Components: kernel
    Affects Versions: 1.1.0
            Reporter: wilesun
             Fix For: 1.1.1


I hope the JPQL supprt the templete:(it can work with hibernate jpa)
select o.id, o.name as aName, o.code aCode form A o where ..

I modifid the jpql.jtt
1.jpql.jtt
void select_expression() #SELECTEXPRESSION : { }
{
	((aggregate_select_expression()
		| LOOKAHEAD(path()) path()
		| identification_variable()
		| (<OBJECT> "(" identification_variable() ")")
		| constructor_expression()
		| select_extension()
		| string_literal()
		| numeric_literal()) [LOOKAHEAD(1)<AS>] [LOOKAHEAD(identification_variable())identification_variable()])
}
2:openjpa-kernel\src\main\java\org\apache\openjpa\kernel\jpql\JPQLExpressionBuilder.java
private Expression assignProjections(JPQLNode parametersNode,
        QueryExpressions exps) {
        int count = parametersNode.getChildCount();
        exps.projections = new Value[count];
        exps.projectionClauses = new String[count];
        exps.projectionAliases = new String[count];

        Expression exp = null;
        for (int i = 0; i < count; i++) {
        	JPQLNode parent = parametersNode.getChild(i);
            JPQLNode projNode = firstChild(parent);
            JPQLNode aliasNode = parent.children.length > 1 ? right(parent) : null;;
            
            Value proj = getValue(projNode);
            String alias = aliasNode == null ? lastChild(projNode).text : aliasNode.text;
            
            exps.projections[i] = proj;
            exps.projectionClauses[i] = assemble(projNode);
            exps.projectionAliases[i] = alias;
        }
        return exp;
    }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message