A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
EJB and other Java EE Technologies
Joined: May 15, 2008
Oct 19, 2008 20:26:00
I want to create a named query, which will return all the names which starts with "ABC", similar to the query below:
select * from customer where name like 'ABC%'
or, if i the
'ABC' is stored in a variable, than above query becomes:
select * from customer where name like name+'%'
I write a named query like this:
select c from customer c where name like :name
its working, but its not waht i want, when i changed the above named query to below:
select c from customer c where name like :name%
Above query gives exception. How to do such thing?
Joined: Nov 24, 2005
Oct 19, 2008 21:56:00
You don't want to append the '%' directly to the name variable, when calling setParameter ?
All roads lead to JavaRanch
I agree. Here's the link:
subject: LIKE operator
Conditions for dependent entites on fetching?
entity loading blues
urgent help reqd
listing hibernate named queries from java
How to do optional wildcard select in JPA named queries?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014