At the beginning, the HQL statement in the project was relatively casual, and later I checked the Query and
Use the name parameter; colon + field name (or alias); equals to the original "? "Name;
String hql = "from User as user where user. name =: name ";
//....
Query. setString ("name", name); // The first parameter must be named the same as that in hql;
= "update LicenceSerialNo set curnum=curnum+1 where curareaid=:organId and areaid=:perType"="organId""perType" i=(i<1) ="from LicenceSerialNo where curareaid=:organId and areaid=:perType"="organId""perType"=(LicenceSerialNo) findQr.list().get(0=licSerial.getLicencetype()+ DecimalFormat("0000"
There are many set methods for query, so you don't need to remember them. You can query them when you use them, and master the distinctive methods, for example,
Query. setfirstResult (0); // you can specify the start position of a query.
Query. setMaxResult (10); // you can specify the number of query records.
The most common query Method
Query. list () query. uniqueResult () set series
Use criterial:
Cr. add () join query restrictions after SQL statements
The Restrictions class provides a query restriction mechanism. It provides many methods to implement query restrictions.
Criteria cr = session.createCriteria(Student.); cr.add(Restrictions.eq("name", "Bill"));List list == (Student)list.get(0