日期:2014-05-20 浏览次数:21101 次
try {
session = HibernateSessionFactory.getSession();
tx = session.beginTransaction();
String hql = "update Maccount set maccount.weekcount = 12 where maccount.id = 1";
Query query = session.createSQLQuery(hql).addEntity("maccount",
Maccount.class).addJoin("id", "maccount.id").addJoin(
"weekcount", "maccount.weekcount");
tx.commit();
} catch (Exception e) {
e.printStackTrace();
if (tx != null) {
tx.rollback();
tx = null;
}
} finally {
if (session != null) {
session.close();
session = null;
}
}