> Hi, I'm also very interested in this thread. I was able to get the
> JBoss-QL LIKE query working with parameters, but could not get it working
> with wildcard characters such as %
>
> for example this query does not work
> query="SELECT OBJECT (C) from Person AS C WHERE ( C.firstName
> LIKE '?1%' )
> OR ( C.lastName LIKE '?1%')"

It does work, it returns all people whose name starts with "?1"

>
> whereas this does
> query="SELECT OBJECT (C) from Person AS C WHERE ( C.firstName LIKE ?1 )
> OR ( C.lastName LIKE ?1)"
>
> so, is there a way to get wildcards + parameters working together ?
> or do we have to write custom finders for those kinds of queries ?
>

The best way is to append the '%' character to the parameter before calling
the finder, for example, when you escape wildcards entered by the user.

You could write "C.lastName LIKE CONCAT(?1, '%')" but that will typically
prevent the database from considering using an index for your query.



-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
The most comprehensive and flexible code editor you can use.
Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
www.slickedit.com/sourceforge
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to