只是想知道在创建 Criteria/Query 等之前或之后 beginTransaction [org.hibernate] 有什么区别吗?
示例 1:
...
Transaction tx= session.beginTransaction();
Criteria c = session.createCriteria(class);
result = c.uniqueResult();
tx.commit();
...
示例 2:
...
Criteria c = session.createCriteria(class);
Transaction tx= session.beginTransaction();
result = c.uniqueResult();
tx.commit();
...
谢谢。