Can anyone tell me how can we use parameter in the comparison pattern for LIKE operator.
For e.g.
select Oject(a) from product a where a.name LIKE 'A%'
works fine but how can we use it
select Oject(a) from product a where a.name LIKE %?1%
where ?1 is parameter from finder function
Help from anyone is highly appreciated
-
LIKE operator in EJB-QL (5 messages)
- Posted by: rajiv Kumar
- Posted on: July 29 2003 08:06 EDT
Threaded Messages (5)
- LIKE operator in EJB-QL by Andrea Vettori on July 29 2003 08:47 EDT
- Thanks for your reply by rajiv Kumar on July 30 2003 00:18 EDT
- Chose your spec or app.server by Jonas Andersen on July 29 2003 20:08 EDT
- Thanks Jonas by rajiv Kumar on July 30 2003 00:19 EDT
- LIKE operator in EJB-QL by hafiz hammad rubani on October 06 2005 05:08 EDT
-
LIKE operator in EJB-QL[ Go to top ]
- Posted by: Andrea Vettori
- Posted on: July 29 2003 08:47 EDT
- in response to rajiv Kumar
Parameters are not permitted bye EJB specification the LIKE operator.
This is because many times it is convenient to write session beans to perform searches throught JBDC direct calls (ORDER BY is another). -
Thanks for your reply[ Go to top ]
- Posted by: rajiv Kumar
- Posted on: July 30 2003 00:18 EDT
- in response to Andrea Vettori
Thanks for your reply -
Chose your spec or app.server[ Go to top ]
- Posted by: Jonas Andersen
- Posted on: July 29 2003 20:08 EDT
- in response to rajiv Kumar
Have been playing around with this myself some time ago.
First, a short look at the EJB specifications:
EJB 2.0: Section 11.2.7.9 Like expresions :
single_valued_path_expression [NOT] LIKE pattern-value [ESCAPE escape-character]
The pattern-value is a string literal ......
EJB 2.1: Section 11.2.6.9 Like expressions :
cmp_path_expression [NOT] LIKE pattern_value [ESCAPE escape_character]
The pattern_value is a string literal or a string-valued
input parameter....
The important difference here is the addition of string-valued input parameter to the definition of pattern_value.
It was a while ago, but if I remember correct IBM WebSphere (don't remember if it was only v5 or also v4) will allow you to use string-valued input parameters in the like clause (I think this is mentioned in the documentation as an IBM extension) (disclaimer, work for IBM, don't speak for them).
I think it was also possible in JBoss to get something like this. It required a special jboss deployment file in your EJB jar, which had and jboss-ql entry or something.
/jonas -
Thanks Jonas[ Go to top ]
- Posted by: rajiv Kumar
- Posted on: July 30 2003 00:19 EDT
- in response to Jonas Andersen
Thanks Jonas -
LIKE operator in EJB-QL[ Go to top ]
- Posted by: hafiz hammad rubani
- Posted on: October 06 2005 05:08 EDT
- in response to rajiv Kumar
hi
as following not allowed in EJBQL
select Oject(a) from product a where a.name LIKE %?1%
but we can appened % sign to both side of the parameter before calling that particular function and it works. e.g
name = "%"+name +"%";
....findByName(name)
findByName(String name){
select Oject(a) from product a where a.name LIKE ?1
}
Hammad