• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think since order by is based on a column name the parameter value should have b.columnname passed to it.
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic