On Tue, Sep 03, 2002 at 06:20:21PM +0200, 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), '%')
What about doing the concat in your java code before supplying it as a parameter? Also
check which functions that are available in EJB/JBoss-ql in standardjbosscmp-jdbc.xml
in conf. There you find mapping for locate etc, which might contain one you neeed.
If it isn't working, you mights need to use dynamic-ql
>
> 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?
>
> thanks in advance
--
MVH
Marius Kotsbak
Boost communications AS
-------------------------------------------------------
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