Like SQL queries, Hibernate and HQL use the like keyword for Fuzzy queries. Fuzzy query can compare whether a string matches the specified string mode. The wildcard character is used as follows: % (percent): matches strings of any type and length. For Chinese characters, two percent signs "%" _ (underline) are required: matches a single character, it is generally used to limit the length of a string expression. Example 1. search for students whose names start with "M": String queryString = "from studentInfo s where s. sname like's % '"; 2. retrieve the student object whose name contains the String "abc": String queryString = "from studentInfo s where s. sname like '% abc %' "; 3. search student objects starting with S and with a String length of 5: String queryString = "from studentInfo s where s. sname like's ____ '"; four underscores" _ "4. example: retrieve all students whose names contain "Wang": String queryString = "from StudentInfo s where s. sname like '% "+ sname +" %' "; note that the HQL statement cannot be spliced. Wrong! DAO: public List findBySname (Object sname) {log. debug ("finding all StudentInfo instances"); try {// String queryString = "from StudentInfo s where s. name like '% "+ sname +" %' "; String queryString =" from StudentInfo s where s. sname like '% "+ sname +" %' "; Query queryObject = getSession (). createQuery (queryString); return queryObject. list ();} catch (RuntimeException re) {log. error ("find all failed ", Re); throw re;} page to output this List set.