日期:2014-05-20 浏览次数:20926 次
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; } }