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%')" 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 ? P.S I'm using 3.0.4 ----- original message --------------------- Date: Sat, 22 Feb 2003 13:12:09 +0100 From: "Langelage, Frank" <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] How to do a 'like' search using CMP in entity beans? Reply-To: [EMAIL PROTECTED] Carsten Hammer wrote: > Hi, > I want to implement a search for all names that begin with 'Sm'. > Monson-Haefel claims this is impossible using EJB QL on a CMP field. > What does this mean? > > It seems to be easy to build queries with a fixed pattern like > > SELECT OBJECT(c) FROM Customer c WHERE c.lastName LIKE '%-%' > > But how to do it if the pattern should be '%<user transmitted pattern>%' > where <user transmitted pattern> is something that I catch from the > GUI of my client application? > > Thanks in advance, > Carsten You have to use a JBoss specific extension called JBoss-QL in this case. In my AddressBean I declare a ejb.finder with a constant expression after like and use a jboss.query with a placeholder instead. XDoclet generates the query in ejb-jar.xml and in jbosscmp-jdbc.xml. * @ejb.finder signature="java.util.Collection findByMatchcode( java.lang.String matchcode )" * view-type="local" * query="SELECT OBJECT(o) FROM Address AS o WHERE o.matchcode LIKE 'SIEMENS%'" * result-type-mapping="Local" * @jboss.query signature="java.util.Collection findByMatchcode( java.lang.String matchcode )" * query="SELECT OBJECT(o) FROM Address AS o WHERE o.matchcode LIKE ?1 ORDER BY o.id" Regards Frank -------------end original message ------------------------- ------------------------------------------------------- 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
