org.hibernate.hql.internal.ast.ErrorCounter reportError

protected void setParames(Query query,Object[]parames){
		if(parames != null && parames.length >0){
			for(int i=0; i entityClass, Object[] entityIds) {
		if (entityIds != null && entityIds.length > 0) {
			StringBuffer jpql = new StringBuffer();
			for (int i = 0; i < entityIds.length; i++) {
				jpql.append('?').append(',');
			}
			jpql.deleteCharAt(jpql.length() - 1);
			Query query = getSession().createQuery("delete  from UploadFile o where o.id in("+ jpql.toString() + ")");
			setParames(query, entityIds);
			System.out.println(query.toString());
			query.executeUpdate();
		}
	}


hibernate中的HQL语句的delete和Mysql中的差别:

在hibernate中只能这样使用

getSession().createQuery("delete  from UploadFile o where o.id in("+ jpql.toString() + ")")
而在mysql中可以

getSession().createQuery("delete o  from UploadFile o where o.id in("+ jpql.toString() + ")")
如果在hibernate中像上面这样使用则会报

org.hibernate.hql.internal.ast.ErrorCounter reportError


你可能感兴趣的:(java,hibernate)