Michael Nowotny wrote:
> Hi folks!
>  
> Using EJB ql it is possible define template queries such as
>  
> SELECT OBJECT(p) FROM Product p where p.name = ?1
>  
> Now - what I'm trying to achieve is the following:
> The query should not only return exact matches but products whose name 
> contains a given search string as well.
> My approach looks like this:
>  
> SELECT OBJECT(p) FROM Product p where p.name LIKE concat(concat('%', 
> ?1), '%')

You can do this with JBossQL in cvs Branch_3_0, Branch_3_2, and HEAD. 
It will be part of the next JBoss release 3.0.3.

> JBoss doesn't accept this because it expects a String literal following 
> the LIKE keyword.
> Even the stripped down version doesn't work:
>  
> SELECT OBJECT(p) FROM Product p where p.name LIKE ?1
>  
> It seems to me that EJB QL only accepts constants following a LIKE 
> statement.
> Is there any way to achieve this kind of task using EJB QL. If not - 
> what other approaches might work in this context?

There is no way to do this with EJB-QL; it is not allowed by the spec. 
You can do it with JBossQL.

-dain



-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to