-
1. Re: LIKE keyword in ejb ql with an input parameter CANT MAKE
sesques Apr 13, 2004 7:46 AM (in response to brian1)Hi,
I use myself* @ejb:finder * signature = "Collection findByLibelle(java.lang.String libelle)" * query = "SELECT OBJECT(o) from PhML_Produit as o WHERE o.prdLibelle LIKE '%?1%'"
and it works fine. -
2. Re: LIKE keyword in ejb ql with an input parameter CANT MAKE
brian1 Apr 13, 2004 8:21 AM (in response to brian1)@ejb.finder * description = "Find a PersonBean whose last name starts with the supplied argument" * query = "SELECT OBJECT(i) FROM Person as i WHERE i.active = 1 AND i.lastName LIKE '?1%'" * signature = "java.util.Collection findByLastName(java.lang.String lastNameStart)"
is exactl what I just built with, and it doesn't find anything. well, it will find people whose last names start with "?1"... what am I missing? -
3. Re: LIKE keyword in ejb ql with an input parameter CANT MAKE
sesques Apr 13, 2004 11:58 AM (in response to brian1)Sorry for the last response. In fact my code does not work, it return nothing like yours.
Regarding the EJB spec, nothing in the spec says that the LIKE keyword in EJB-QL statement must work with input parameters. The only example is with literal strings. So the LIKE statement in EJB-QL is useless, in conclusion.
You must use a @jboss.query for that, but passing the % in the parameter.@ejb.finder * query = "SELECT OBJECT(i) FROM Person as i WHERE i.active = 1 AND i.lastName LIKE '?1%'" * signature = "java.util.Collection findByLastName(java.lang.String lastNameStart)" @jboss.query * query = "SELECT OBJECT(i) FROM Person as i WHERE i.active = 1 AND i.lastName LIKE ?1" * signature = "java.util.Collection findByLastName(java.lang.String lastNameStart)"
Then you can call it like this:Person.findByLastName(yourpattern+"%")
-
4. Re: LIKE keyword in ejb ql with an input parameter CANT MAKE
brian1 Apr 13, 2004 12:23 PM (in response to brian1)Horay Horay Horay !!! that works beautifully. I no wish I should have looked closer at the jboss specific way to override finders.... I am new to JBoss and EJB in general. I suppose the spec does not specifically give an example of using input params in finders with LIKE... I am off to ask some questions on sun's boards now, as it seems a bit odd. the BNF for EJB QL says you can use a string expression with like, and CONCAT should be a String Expression... at least that's how I read it. Anyway, thank you. If there is anything I can do, let me know, as the ability to search in this way is very important in my app. Thanks again.
-
5. Re: LIKE keyword in ejb ql with an input parameter CANT MAKE
jimboinlondon May 5, 2004 10:21 AM (in response to brian1)Blimey. I was trying to do this all this aft. and you chaps have solved my
problem. Thanks.
James -
6. Re: LIKE keyword in ejb ql with an input parameter CANT MAKE
ram_iyer May 23, 2004 5:45 PM (in response to brian1)thanks to sesques! it works!!
i have had a couple of frustrating days trying to solve the 'like ?1%' problem.