Hi,could somebody put an example of how to use a wildcard % with named parameters,I know do it in a SQLQuery
String sql = "select * from tablename where fieldname1 like ? ;
SQLQuery query = session.createSQLQuery(sql);
query.addEntity(classname.class);
query.setString(0,"%"+fieldname1+"%");
that's work fine
but I want to do it with named paramaters,where we have to put the % wildcard?
String queryString = "from " + classname.class.getName() + " e where e.nombre like :nombre ";
List list = hibernateTemplate.findByNamedParam(queryString,"nombre", nombre);
return list;
}
If we put the widcards inside the String of the query eg where e.field like :nombre%";
throws an unexpected '%'
Also I tested put in hibernateTemplate.findByNamedParam(queryString,"%nombre%", nombre);
throws an cannot locate named parameter [%nombre%].
Can we use wildcards with hibernate named parameters??
|