aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes needs help for EJBQL  query 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 "needs help for EJBQL  query" Watch "needs help for EJBQL  query" New topic
Author

needs help for EJBQL query

Lalit Nagalkar
Ranch Hand

Joined: Aug 22, 2006
Posts: 47
hi everybody
I am using following EJBQL query in my app deployed succesfully on jBoss 4.0.4
But I am not getting anything from the querry the size of result is always 0 I mean the querry retuns no elements from the DB but there are rows satisfying the query.
------------------------------------------------
method signature:> public java.util.Collection findByName(String name)throws FinderException, RemoteException

EJBQL:> SELECT OBJECT(a) FROM item AS a WHERE a.name LIKE '%?1%'
------------------------------------------------

Also is there any tool that can show what class and/or querry the container has generated for our CMP-EJB and EJBQL.

Thanks,
Lalit


SCJP 1.4
Debu Panda
author
Ranch Hand

Joined: Jan 21, 2007
Posts: 100
I'm not a JBoss expert. But you can use P6SPY to see what SQL was executed by a CMP engine.http://www.p6spy.com/documentation/index.htm

If I remember correctly EJBQL does not allow %with a parameter

Can you try changing:

a.name LIKE '%?1%'

To

a.name LIKE '?1'

Pass the parameter that has % as follows:

'%'+mystring+'%'


Author: EJB 3 In Action (http://manning.com/panda)
Debu Panda
author
Ranch Hand

Joined: Jan 21, 2007
Posts: 100
another way to get it around by using

like CONCAT('%',CONCAT(?1,'%'))
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Yes, I think it was the same for JDBC.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: needs help for EJBQL query