-
1. Re: Unable to parse EJB-QL
mahaffey Apr 7, 2002 10:19 PM (in response to jfifield)Just a shot...but do you have the query in a CDATA
section? If not, the parser is probably getting
erros trying to parse the greater than/less than
brackets.
<ejb-ql>
<![CDATA[
SELECT OBJECT(o) FROM CalendarEvent AS o
WHERE o.user.id = ?1 AND
o.startDate >= ?2 AND o.startDate <= ?3
]]>
</ejb-ql> -
2. Re: Unable to parse EJB-QL
jfifield Apr 8, 2002 7:09 AM (in response to jfifield)Yes. Sorry, I should have mentioned that. Here is the whole section:
<query> <query-method> <method-name>findByDateRange</method-name> <method-params> <method-param>java.lang.Integer</method-param> <method-param>java.util.Date</method-param> <method-param>java.util.Date</method-param> </method-params> </query-method> <ejb-ql> <![CDATA[SELECT OBJECT(o) FROM CalendarEvent AS o WHERE o.user.id = ?1 AND o.startDate >= ?2 AND o.startDate <= ?3]]> </ejb-ql> </query>
Joe -
3. Re: Unable to parse EJB-QL
chrismein Apr 10, 2002 9:35 AM (in response to jfifield)Did you have any luck sorting out this problem?
I have a similar piece of EJB-QL:
<query-method>
<method-name>findByReservationId</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql><![CDATA[SELECT OBJECT(o) FROM RESERVATIONS AS o WHERE o.BOOKING_REF = ?1]]>
</ejb-ql>
And I get the same error...
org.jboss.deployment.DeploymentException: Unable to parse EJB-QL: SELECT OBJECT(o) FROM RESERVATIONS AS o WHERE o.BOOKING_REF = ?1
Can anybody help. I am using the 3.0.0 beta distribution.
Thanks
Chris Mein -
4. Re: Unable to parse EJB-QL
chrismein Apr 10, 2002 10:03 AM (in response to jfifield)Sorry incorrect name, and an incorrect post!
However I am now having the following problem... with the following declaration
<query-method>
<method-name>findByReservationId</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<result-type-mapping>Remote</result-type-mapping>
<ejb-ql><![CDATA[SELECT OBJECT(o) FROM ReservationsBean AS o WHERE o.reservationId = ?1]]></ejb-ql>
I get the following generated SQL:
SELECT t1_o.RESERVATION_ID FROM RESERVATIONS t1_o WHERE t1_o.RESERVATION_ID = ?
The problem is I wanted an object back not a list of the primary key values.
What am I doing wrong this time, and I don't think its the spelling.
Chris -
5. Re: Unable to parse EJB-QL
jfifield Apr 10, 2002 6:07 PM (in response to jfifield)First: No, I haven't solved my problem yet :( If anyone has any insight into the problem described in the first message, I would be most grateful.
Second: I was under the impression that a finder normally selected primary keys, then the container returns a collection of component interfaces matching those pk's. Last I knew, executing a finder and looping through the results meant n + 1 SELECT's. The container may do optimization in this area, not sure though. Maybe someone else has a better idea...
Joe -
6. Re: Unable to parse EJB-QL
kantek Apr 12, 2002 4:17 PM (in response to jfifield)I have the same problem IF I don't put the security
JBoss can't parse my query.
ex:
<security-identity>
<use-caller-identity />
</security-identity>
<query-method>
<method-name>findAll</method-name>
<method-params />
</query-method>
<ejb-ql>
<![CDATA[ SELECT DISTINCT OBJECT(p) FROM Pessoa As p
]]>
</ejb-ql> -
7. Re: Unable to parse EJB-QL
jfifield Apr 13, 2002 8:28 AM (in response to jfifield)Thanks for the idea, but unfortunately still getting the same error :( I'll keep working on it!
Joe -
8. Re: Unable to parse EJB-QL
jfifield Apr 13, 2002 4:57 PM (in response to jfifield)Ok, I got a little more info. I checked out and built the newest from CVS (4/13) and tried it again. I got the same error, but with a more descriptive message:
org.jboss.deployment.DeploymentException: Error compiling ejbql; - nested throwable is: org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered ">=" at line 3, column 57.
Was expecting one of:
">" ...
"<" ...
"=" ...
"<>" ...
Well, this tells me for sure it's unhappy about the ">=", and sure enough, replacing the ">=" and "<=" with ">" and "<" works great. But why doesn't it accept ">=" and "<="? I may be misinterpreting the EJB2 spec, but it seems that ">=" and "<=" should in fact be legal.
Can anyone shed some light on this situation? Thanks!
Joe -
9. Re: Unable to parse EJB-QL
prabha Apr 16, 2002 10:14 AM (in response to jfifield)Did you find any solutions for this? I see the same error if I have where clause in my EJB-QL. I tried to re-write the query several times, but continued to get this error. However, if I remove the where clause in my EJB-QL, I don't see this error.
To overcome this, I am using declared sql and that works fine.
Prabha. -
10. Re: Unable to parse EJB-QL
jfifield Apr 16, 2002 6:31 PM (in response to jfifield)Nope, no solutions yet. Unfortunately I haven't had alot of time to do any more work on it in the last couple of days.
Joe -
11. Re: Unable to parse EJB-QL
scar Apr 17, 2002 4:43 AM (in response to jfifield)Hi.
I have the same problem with parsing due deploying.
I need to pass paramether as pattern for next searching. I am interesting in sending
different kinds of patterns into SQL-line (with "=", "<", " LIKE '...' " and so on).
I have tried to do something like that (in ejb-jar.xml file)
:
<query-method>
<method-name>findByTin</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<result-type-mapping>Local</result-type-mapping>
<ejb-ql>![CDATA[select OBJECT(p) from PmInfoPrimary p where p.tin like ?1]]</ejb-ql>
but got "Unable to parse EJB-QL" error due deploying.
I have tried another variants of ? paramether:
select OBJECT(p) from PmInfoPrimary p where p.tin ?1 -- does not work (error due deploying);
select OBJECT(p) from PmInfoPrimary p where p.tin = ?1 -- work correctly (deploying - ok, using - ok);
select OBJECT(p) from PmInfoPrimary p where p.tin like ?1 -- does not work (error due deploying);
select OBJECT(p) from PmInfoPrimary p where p.tin like '?1' -- deploying was ok, but I can't got any data from bean using this line (in case where pattern was '%my_str%, for example);
I have tried using <ejb-ql> block paramethers without " ![CDATA ..." and result was the same.
I am very interesting in using LIKE inside my <ejb-ql> block, but I can not find any decision in my problem.
I am using the 3.0.0 beta distribution.
Can anyone help please. Thanx a lot for advice. -
12. Re: Unable to parse EJB-QL
feuxeu77 Apr 17, 2002 10:54 AM (in response to jfifield)I'm not sure, but I had this error and, to correct it, I had to declare the query-method in the jbosscmp-jdbc.xml too. To see how to do this, go to this thread : http://main.jboss.org/thread.jsp?forum=46&thread=13142
FX -
13. Re: Unable to parse EJB-QL
dsundstrom Apr 18, 2002 1:01 PM (in response to jfifield)I'll try to clear up all of the problems that I can remember from the posts.
date types can't use the >= or <= opperators. Use the >, < and = opperators in multiple ands. Yes this sucks. Maybe I'll >= and <= support to jboss-ql
parameters in like: use jboss-ql, which is defined in the jbosscmp-jdbc.xml file. The specification looks exactally like ejb-ql except it is called jboss-ql.
Also, everyone upgrade to the RC1 release. I have fixed soooo many bugs. -
14. Re: Unable to parse EJB-QL
prabha Apr 18, 2002 7:40 PM (in response to jfifield)How do I upgrade to RC1? I couldn't find any information in the downloads section... I have jboss3.0.0 beta installed.
Thanks,
Prabha.