wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes EJB QL Problem in both EJB2.0 & EJB 2.1... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB QL Problem in both EJB2.0 & EJB 2.1..." Watch "EJB QL Problem in both EJB2.0 & EJB 2.1..." New topic
Author

EJB QL Problem in both EJB2.0 & EJB 2.1...

Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
Hi,
I am developing my CMP EJB's using EJB 2.0 Specification. In my one of CMP EJB there is a ejb-finder method with EJB QL as following:-
============================================================
"SELECT Object(b) FROM PartsMaster as b where b.partno like ?1 or b.description like ?2 ORDER BY ?3"
=============================================================
But when I am deploying my Bean to my application server (I am using JBOSS4.0), I am getting Error as follows:-
=======================================================
18:33:30,359 WARN [ServiceController] Problem starting service jboss.j2ee:jndiName=ejb/PartsDetail,service=EJB
org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement 'SELECT Object(b) FROM PartsMaster as b where b.partno like ?1 or b.description like ?2 ORDER BY ?3'; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "3" at line 1, column 97.
Was expecting one of:
<NUMERIC_VALUED_PATH> ...
<STRING_VALUED_PATH> ...
<DATETIME_VALUED_PATH> ...
)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.<init>(JDBCEJBQLQuery.java:52)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createEJBQLQuery(JDBCCommandFactory.java:60)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCQueryManager.start(JDBCQueryManager.java:272)
=======================================================

However above EJB Query is working fine without "ORDER BY" Clause into it.
Later I came to know that EJB 2.0 not supports "ORDER BY" clause in EJB QL, So I modified my ejb-jar.xml's DTD as follows so that it would be compatible with EJB2.1:-
================
<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1">
================

But again I am getting same error as above when I am deploying my bean.
Can anybody tell me how to solve this problem using EJB QL only? I don't want to use JBOSS QL here.
Please help me.
Thanx in advance.
Pras


********Deserve Before You Desire********
Andr� Latour
Greenhorn

Joined: May 22, 2006
Posts: 15
Hello Prashant,

this is only an idea. Is the parameter b.partno a numeric value? In this case i do not know if it is possible to query a numeric value with 'like'.


... as i said, only an idea....

Regards,
Andr�
[ July 17, 2006: Message edited by: Andr� Latour ]
Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
Hi,
My "b.partno" is string and I don't have any problem regarding it in my above EJBQL Query.
Only I have problem with "ORDER BY" Clause, as i am not able to include it in my EJBQL.
as far as i know "ORDER BY" clause in EJBQL is supported in EJB 2.1 Spec. onwards. But here I am not able to include "ORDER BY" in my EJBQL though currently my EJB spec is 2.1, Can anybody tell me why it is happening?
Also If I want to use it through JBOSSQL how should I write it?
Thanx.
Pras
Abhishekh Padmanabhan
Greenhorn

Joined: Sep 26, 2006
Posts: 5
I think since order by is based on a column name the parameter value should have b.columnname passed to it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB QL Problem in both EJB2.0 & EJB 2.1...