Criteria cri = session
cri
list cri
實質
則這個表中的所有的giftortoy為
session = this
Criteria cri = session
Criterion cron = Restrictions
cri
list = cri
比較運算符
HQL運算符 QBC運算符 含義
=Restrictions
<> Restrictions
>Restrictions
>= Restrictions
is null Restrictions.isnull() 等於空值
is not nullRestrictions.isNotNull() 非空值
like Restrictions.like() 字符串模式匹配
and Restrictions.and() 邏輯與
and njunction()邏輯與
or Restrictions.or()邏輯或
or Restrictions.disjunction()邏輯或
notRestrictions.not() 邏輯非
in(列表) Restrictions.in()等於列表中的某一個值
ont in(列表)Restrictions.not(Restrictions.in())不等於列表中任意一個值
between x and yRestrictions.between() 閉區間xy中的任意值
not between x and y Restrictions.not(Restrictions..between()) 小於值X或者大於值y
3: HQL
String hql = "select s.name ,avg(s.age) from Student s group by s.name";
Query query = session.createQuery(hql);
list = query.list();
....
4: 本地SQL查詢
session = sessionFactory.openSession();
tran = session.beginTransaction();
SQLQuery sq = session.createSQLQuery(sql);
sq.addEntity(Student.class);
list = sq.list();
mit();
5: QID
Session的get()和load()方法提供了根據對象ID來檢索對象的方式。tW.wiNGWIt.COM該方式被用於事先知道了要檢索對象ID的情況。
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28308.html