0

I have an HQL query like:-

String sql = "select s from table1 m , table2 s where  s.id= m.sId and " '" + path + "'  like  concat(m.path,'/%') ";

This is running fine and path here is a String. Now what i want to do here is that i will have a list of paths of String type. And i want a single query to do my work i.e return s for all of the paths. Can i do this in a single query?

Harinder
  • 11,776
  • 16
  • 70
  • 126
  • 1
    you need to add a dynamic query with an OR condition eg: (like concat(m.path1,'/%') or like concat(m.path2,'/%')) otherwise you need to move it to a procedure Refer the answer given below http://stackoverflow.com/questions/13615875/how-to-avoid-inline-sql-when-using-like-clause-with-variable-number-of-parameter – Raghu Nov 28 '13 at 06:29
  • Dynamically constructed searches is where using a query builder really shines. See Hibernate Criteria API http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/querycriteria.html or JPA Criteria API http://docs.oracle.com/javaee/6/tutorial/doc/gjitv.html – carbontax Nov 29 '13 at 13:04

0 Answers0