Wildcard « Query « JPA Q&A





1. How to escape wildcard characters in "like" clause in HQL?    stackoverflow.com

How can I escape the wildcard characters in a like clause? E.g.:

select foo from Foo as foo where foo.bar like '%' || :filter ||'%'
query.setParameter("filter", "%");
query.list(); 
// I'd expect to get the foo's ...

2. JPA: build a query with wildcards using entities    forums.netbeans.org

Hi, I need to create a query with wildcard so the user could filter the data. In a simple SQL query I can use the word 'LIKE' to specify a value for a paramter in a WHERE clause or if the user did'nt choose any filter I pass '%' to the LIKE clause and I get all the rows. But using ...

3. Add wildcards in an "in" clause in HQL?    coderanch.com

Suppose I have a list of countries in a database column. The user enters a list of characters (eg. 'I','J','U',...) to fetch the names of those countries which start with the given character. I would normally do it in SQL as select * from countries where country_name like 'I%' or country_name like 'J%' or country_name like '..' or ................ I think, ...

4. Hibernate Wildcard Query    coderanch.com

I have a column that I need to do a wildcard query on. For example, if I put in "bob", I should get back "jim bob", "joe bob", and "bobbie". However, I can't seem to get the query to work. I tried just adding % to the front and back of the variable, but then Hibernate gives me an unexpected char ...

5. How to do optional wildcard select in JPA named queries?    coderanch.com

Hi everyone, Say I have a Record entity with 3 fields a, b and c, and given a Record instance rec, I use r's fields as criteria for a predefined (named) SELECT query (with AND on all fields). Does JPQL allow us to write a query that can do wildcard matches on fields that are null? eg. if rec has all ...

7. Multiple choice wildcard query    forum.hibernate.org

8. using a wildcard in the 'like' where clause    forum.hibernate.org

Hi, I'm very new to hibernate, and I'm making a small change to an existing site. THe current search page doesn't use wildcards for the various string fields. So I want to add this in. Short Story: The query and param values are sent to hibernate like so: getHibernateTemplate().find(query, valuesList.toArray()); Is this not valid for HQL?: like '%?%' Long Story: The ...

9. wildcard "%" (in like) not working in placeholders    forum.hibernate.org

Newbie Joined: Fri Aug 17, 2007 5:45 am Posts: 6 Hibernate version: 1.3.1 Name and version of the database you are using: Oracle 10i Hello, I have the next callbak DAO method: Code: public Vmenstrans[] findByCodnt( final String startdate, ...





10. Use of wildcards in subqueries in HQL    forum.hibernate.org

Hey guys, I have a problem and i couldnt solve it with an elegant solution. One stupid but representative example is: from Parent p where p.name in (select c.parent_name from Children c where c.name='John') Another example would be: from Parent p where exists (from Children c where p.name = c.parent_name) This is ok... but.. If my subquery returns parent's name containing ...