1: QBE (query by example)
Criteria CRI = session. createcriteria (student. Class); CRI. Add (example. Create (s); // s is a student object listcri. List ();
Essence: Create a template. For example, I have a table serial with a giftortoy field. I set serial. setgifttoy ("2 "),
All the giftortoy Data in this table is returned.
2: QBC (query bycriteria) mainly consists of criteria, criterion, Oder, restrictions class
Session = This. getsession (); Criteria
CRI = session. createcriteria (jditemserialnumber. Class); Criterion
Cron = restrictions. Like ("customer", name); CRI. Add (cron); List = CRI. List ();
Comparison Operators
Hql operator QBC operator meaning
= Restrictions. eq () equals
<> Restrictions. Not (exprission. eq () is not equal
> Restrictions. gt () is greater
> = Restrictions. Ge () is greater than or equal
<= Restrictions. Le () is less than or equal
Is null restrictions. isnull () is null
Is not nullrestrictions. isnotnull () non-null
Like restrictions. Like () string mode matching
And restrictions. And () logic and
And restrictions. conjunction () logic and
Or restrictions. Or () logic or
Or restrictions. disjunction () logic or
Notrestrictions. Not () logical non-
In (list) restrictions. In () is equal to a value in the list.
ONT in (list) restrictions. Not (restrictions. In () is not equal to any value in the list
Any value in between x and yrestrictions. Between () closed range XY
Not between x and yrestrictions. Not (restrictions... between () is smaller than the value x or greater than the value Y
3: hql
String hql = "select S. Name, AVG (S. Age) from student s
Groupbys. Name "; query =
Session. createquery (hql); List = query. List ();....
4: Local SQL query
5: qid
The get () and load () Methods of the session provide the way to retrieve Objects Based on the Object ID. This method is used to know the ID of the object to be retrieved in advance.
Edit recommendations
Layer-by-layer parsing of abuse of transactions in hibernate
Questions about STRUTS + hibernate Paging
Perfect Combination of struts and Hibernate
Six things you must know about hibernate