hibernate 执行sql 语句 批量删除和更新

更新方法
public void executeUpdateSql(final String sql)throws DataAccessException
{
		this.getSession().createSQLQuery(sql).executeUpdate();
		this.getSession().flush(); //清理缓存,执行批量插入
		  this.getSession().clear(); //清空缓存中的 对象
}
删除方法
    public void deleteBySql(String delsql) throws HibernateException, SQLException{
    	this.getSession().createSQLQuery(delsql).executeUpdate();
    	this.getSession().flush(); //清理缓存,执行批量插入
		this.getSession().clear(); //清空缓存中的 对象
		
    }
 

猜你喜欢

转载自01jiangwei01.iteye.com/blog/1270684