You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Sreedhar.sirigiri" <sr...@gmail.com> on 2007/07/04 15:41:27 UTC

JPQL Exception

Hi All,

I'm using the following code to execute JPQL.

			StringBuffer strBuff = new StringBuffer(30);
			strBuff.append("select model from UserDTO model ");
            if (name != null && name.length() > 0) {
				strBuff.append(" where UPPER(model.name) like
'%"+(name.toUpperCase())+"%' ");
			}
			strBuff.append(" order by UPPER(model.name) asc");

But I get the following exception. When I remove UPPER in the last line of
code it is executing without any failure. Shouldn't I use UPPER after
order?? What I could make out from the following trace is, JPQL is expecting
a column name instead of a UPPER(model.name). Any help or suggestions.

<0.9.7-incubating nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: An error occurred while
parsing the query filter 'select model from UserDTO model  order by
UPPER(model.name) asc'. Error message: <0.9.7-incubating nonfatal user
error> org.apache.openjpa.kernel.jpql.ParseException: Encountered "UPPER" at
character 43, but expected: [<IDENTIFIER>].

Sreedhar
-- 
View this message in context: http://www.nabble.com/JPQL-Exception-tf4024517.html#a11431186
Sent from the OpenJPA Developers mailing list archive at Nabble.com.


Re: JPQL Exception

Posted by Patrick Linskey <pl...@gmail.com>.
You might want to track
https://issues.apache.org/jira/browse/OPENJPA-273, which indirectly
allows functions to be used in GROUP BY clauses in OpenJPA.

-Patrick

On 7/4/07, Michael Bouschen <mb...@spree.de> wrote:
> Hi Sreedhar,
>
> according to the JPQL spec you cannot use functions in an ORDER BY
> expression, only state field path expressions are allowed.
>
> Regards Michael
>
>
> > Hi All,
> >
> > I'm using the following code to execute JPQL.
> >
> >                       StringBuffer strBuff = new StringBuffer(30);
> >                       strBuff.append("select model from UserDTO model ");
> >             if (name != null && name.length() > 0) {
> >                               strBuff.append(" where UPPER(model.name) like
> > '%"+(name.toUpperCase())+"%' ");
> >                       }
> >                       strBuff.append(" order by UPPER(model.name) asc");
> >
> > But I get the following exception. When I remove UPPER in the last line of
> > code it is executing without any failure. Shouldn't I use UPPER after
> > order?? What I could make out from the following trace is, JPQL is expecting
> > a column name instead of a UPPER(model.name). Any help or suggestions.
> >
> > <0.9.7-incubating nonfatal user error>
> > org.apache.openjpa.persistence.ArgumentException: An error occurred while
> > parsing the query filter 'select model from UserDTO model  order by
> > UPPER(model.name) asc'. Error message: <0.9.7-incubating nonfatal user
> > error> org.apache.openjpa.kernel.jpql.ParseException: Encountered "UPPER" at
> > character 43, but expected: [<IDENTIFIER>].
> >
> > Sreedhar
> >
>
>
> --
> Tech@Spree Engineering GmbH  Tel.: +49/(0)30/235 520-33
> Buelowstr. 66                Fax.: +49/(0)30/217 520-12
> 10783 Berlin                 mailto:mbo.tech@spree.de
>
> Geschaeftsfuehrung: Anna-Kristin Proefrock
> Sitz Berlin, Amtsgericht Charlottenburg, HRB 564 52
>
>


-- 
Patrick Linskey
202 669 5907

Re: JPQL Exception

Posted by Michael Bouschen <mb...@spree.de>.
Hi Sreedhar,

according to the JPQL spec you cannot use functions in an ORDER BY 
expression, only state field path expressions are allowed.

Regards Michael


> Hi All,
>
> I'm using the following code to execute JPQL.
>
> 			StringBuffer strBuff = new StringBuffer(30);
> 			strBuff.append("select model from UserDTO model ");
>             if (name != null && name.length() > 0) {
> 				strBuff.append(" where UPPER(model.name) like
> '%"+(name.toUpperCase())+"%' ");
> 			}
> 			strBuff.append(" order by UPPER(model.name) asc");
>
> But I get the following exception. When I remove UPPER in the last line of
> code it is executing without any failure. Shouldn't I use UPPER after
> order?? What I could make out from the following trace is, JPQL is expecting
> a column name instead of a UPPER(model.name). Any help or suggestions.
>
> <0.9.7-incubating nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: An error occurred while
> parsing the query filter 'select model from UserDTO model  order by
> UPPER(model.name) asc'. Error message: <0.9.7-incubating nonfatal user
> error> org.apache.openjpa.kernel.jpql.ParseException: Encountered "UPPER" at
> character 43, but expected: [<IDENTIFIER>].
>
> Sreedhar
>   


-- 
Tech@Spree Engineering GmbH  Tel.: +49/(0)30/235 520-33
Buelowstr. 66                Fax.: +49/(0)30/217 520-12
10783 Berlin                 mailto:mbo.tech@spree.de 
 
Geschaeftsfuehrung: Anna-Kristin Proefrock
Sitz Berlin, Amtsgericht Charlottenburg, HRB 564 52