<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="txManager" />
@Transactional
public class ProvinceDAO extends HibernateDaoSupport implements ProvinceDAOImpl {
public void updatePinYinById(List list) {
for (Object object : list) {
Province province = (Province) object;
String hql = "UPDATE Province p SET p.pinyin=:pinyin WHERE p.id=:id ";
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery(hql);
query.setParameter("id", province.getId());
query.setParameter("pinyin", province.getPinyin());
query.executeUpdate();
}
}
}
我在批量更新时,会出错。但是不回滚,