Session session = This.getsession ();
String hql = "from Tblfwxx FW where fw.title like?";
Query query = session.createquery (HQL);
Query.setstring (0, "% brilliant Son");
Use the above. "As placeholders, and then set the values of the parameters one by one using the SetString method of query. However, this reduces the readability of the code.
So try to use "named parameter query" to solve these problems later.
Change the HQL statement above to: String hql = "from Tblfwxx FW where Fw.tltle like:zt";
Query query = session.createquery (HQL);
Query.setstring ("zt", "Yan Son");
=============================
I've talked about the criteria query (and also the object query).
The criteria object encapsulates the query criteria, and provides restrictions and other categories for assistance. (For specific usage, find network resources)
Example: Public List search (tblfwxx condition) {
Session session = This.getsession ();
Criteria C = Session.createcriteria (Tblfwxx.class);
if (null! = condition) {
if (condition.gettitle () = null &&!condition.gettitle (). Equals ("")) {
C.add (Restrictions.like ("title", Condition.gettitle (), matchmode.anywhere));
}
}
}