[ 
https://issues.apache.org/jira/browse/OPENJPA-690?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Richard Zowalla resolved OPENJPA-690.
-------------------------------------
    Resolution: Fixed

Already fixed in an earlier release (select item aliases are supported by the 
JPQL grammar (TestJPQLScalarExpressions)); closing.

> 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
>            Priority: Major
>             Fix For: 1.3.0
>
>
> 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 was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to