You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Ognjen Blagojevic <og...@etf.bg.ac.yu> on 2007/06/13 11:03:39 UTC

Error parsingEJB QL query (openjpa 0.9.7)

Hi all,

I have problem with EJBQL query in orm.xml file. If the query is 
single-line, like this:

<named-query name="Test.findAll">
    <query>
        select o from Test o
    </query>
</named-query>

then everything works just fine. But if I i try to split it into several 
lines, like this:

<named-query name="Test.findAll">
    <query>
        select o
          from Test o
    </query>
</named-query>

then I get the following exception (reformated for clarity):

<0.9.7-incubating nonfatal user error> 
org.apache.openjpa.persistence.ArgumentException:
An error occurred while parsing the query filter

           'select o
          from Test o'.
              
Error message: org.apache.openjpa.kernel.jpql.TokenMgrError: Lexical 
error at line 1, column 10.  Encountered: "\n" (10), after : ""

    at 
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1656)
    at 
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.<init>(JPQLExpressionBuilder.java:1639)
    at org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:47)
...

Ani hints? How can I make a multi-line query?

Thanks,
Ognjen


Re: Error parsingEJB QL query (openjpa 0.9.7)

Posted by Ognjen Blagojevic <og...@etf.bg.ac.yu>.
Hi Marc,

> It seems like a reasonable enhancement. Do you want to open a jira issue 
> for it?

Yes, here it is: OPENJPA-259. I hope it's ok.


> If you are interested in making a patch with the enhancement, the parser 
> is at 
> openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt

I don't have any experience with JavaCC, or any other parser for that 
matter.


Regards,
Ognjen

Re: Error parsingEJB QL query (openjpa 0.9.7)

Posted by Marc Prud'hommeaux <mp...@apache.org>.
Ognjen-

It seems like a reasonable enhancement. Do you want to open a jira  
issue for it?

If you are interested in making a patch with the enhancement, the  
parser is at openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/ 
jpql/JPQL.jjt



On Jun 13, 2007, at 6:11 PM, Ognjen Blagojevic wrote:

> Hi Marc,
>
>> The specification doesn't appear to say whether or not a newline  
>> is allowed in queries or not. Our parser seems to disallow it, so  
>> I don't think it is currently possible to have a query with a  
>> newline in it.
>
> The query I gave as an example is really a simple one (select o  
> from Object o), but I think that it would be much easier for the  
> developer if he can structure complex queries in several lines.
>
> Is there a possibility to remove this restriction from the parser?
>
>
> Ognjen


RE: Error parsingEJB QL query (openjpa 0.9.7)

Posted by Brad L Vandermoon <br...@statefarm.com>.
I've run into this issue as well.  This "formatting" ability suggested
by Ognjen would sure make the queries much easier to read and understand
by others.

-----Original Message-----
From: Ognjen Blagojevic [mailto:ognjen@etf.bg.ac.yu] 
Sent: Wednesday, June 13, 2007 5:12 AM
To: dev@openjpa.apache.org
Subject: Re: Error parsingEJB QL query (openjpa 0.9.7)

Hi Marc,

> The specification doesn't appear to say whether or not a newline is 
> allowed in queries or not. Our parser seems to disallow it, so I don't

> think it is currently possible to have a query with a newline in it.

The query I gave as an example is really a simple one (select o from
Object o), but I think that it would be much easier for the developer if
he can structure complex queries in several lines.

Is there a possibility to remove this restriction from the parser?


Ognjen


Re: Error parsingEJB QL query (openjpa 0.9.7)

Posted by Ognjen Blagojevic <og...@etf.bg.ac.yu>.
Hi Marc,

> The specification doesn't appear to say whether or not a newline is 
> allowed in queries or not. Our parser seems to disallow it, so I don't 
> think it is currently possible to have a query with a newline in it.

The query I gave as an example is really a simple one (select o from 
Object o), but I think that it would be much easier for the developer if 
he can structure complex queries in several lines.

Is there a possibility to remove this restriction from the parser?


Ognjen

Re: Error parsingEJB QL query (openjpa 0.9.7)

Posted by Marc Prud'hommeaux <mp...@apache.org>.
Ognjen-

The specification doesn't appear to say whether or not a newline is  
allowed in queries or not. Our parser seems to disallow it, so I  
don't think it is currently possible to have a query with a newline  
in it.


On Jun 13, 2007, at 5:03 PM, Ognjen Blagojevic wrote:

> Hi all,
>
> I have problem with EJBQL query in orm.xml file. If the query is  
> single-line, like this:
>
> <named-query name="Test.findAll">
>    <query>
>        select o from Test o
>    </query>
> </named-query>
>
> then everything works just fine. But if I i try to split it into  
> several lines, like this:
>
> <named-query name="Test.findAll">
>    <query>
>        select o
>          from Test o
>    </query>
> </named-query>
>
> then I get the following exception (reformated for clarity):
>
> <0.9.7-incubating nonfatal user error>  
> org.apache.openjpa.persistence.ArgumentException:
> An error occurred while parsing the query filter
>
>           'select o
>          from Test o'.
>              Error message:  
> org.apache.openjpa.kernel.jpql.TokenMgrError: Lexical error at line  
> 1, column 10.  Encountered: "\n" (10), after : ""
>
>    at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder 
> $ParsedJPQL.parse(JPQLExpressionBuilder.java:1656)
>    at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder 
> $ParsedJPQL.<init>(JPQLExpressionBuilder.java:1639)
>    at org.apache.openjpa.kernel.jpql.JPQLParser.parse 
> (JPQLParser.java:47)
> ...
>
> Ani hints? How can I make a multi-line query?
>
> Thanks,
> Ognjen
>