开发者社区 问答 正文

Spring3+hibernate3 在dao层使用Query的executeUpdate不回滚

Dao层

@Override

public int updateRetrailState(Integer orsa_id, int srcState,
int targetState, String userName) {
String hql="update RBSaleruoverapp ap set ap.oroaState = :oroaState ,ap.oroaReviewnametwo=:oroaReviewnametwo where ap.oroaId=:oroaId and ap.oroaState = :checkOroaState";
Session session=getSession();
// Transaction transaction= session.beginTransaction();
Query query= session.createQuery(hql);
query.setParameter("oroaState", RBSaleruoverapp.STATE_REPEATED);
query.setParameter("oroaReviewnametwo", userName);
query.setParameter("oroaId", orsa_id);
query.setParameter("checkOroaState", RBSaleruoverapp.STATE_FIRST);
int i = query.executeUpdate();
System.out.println("修改完毕");
// transaction.rollback();
return i;
}

service层出错不回滚,但是在sessionFactory.getCurrentSession().saveOrUpdate()方法就可以回滚为什么?

展开
收起
a123456678 2016-03-17 15:09:15 2509 分享 版权
1 条回答
写回答
取消 提交回答
  • 配置事物没有?getCurrentSession()获取session要配置: org.springframework.orm.hibernate4.SpringSessionContext

    </prop>
    2019-07-17 19:05:28
    赞同 展开评论