是否可以在HQL查询中更新用户类型字段?
当我尝试在where子句中使用用户类型时,一切正常。
getSession()
.createQuery("update " + AvatarDataSet.class.getName() + " set removed=false where id=:avatarId and position =:pos ")
.setParameter("pos", ds.getPosition(), Hibernate.custom(ConstPointUserType.class))
.setParameter("avatarId", ds.getPersistentId().getLongId())
.executeUpdate();
update avatar set is_removed=false where Id=? and position_x=? and position_y=? and position_z=?
但是当我尝试将用户类型用作要更新的字段时,我得到一个例外。好像hibernate试图在sql字符串“position_x =?和position_y =?and position_z =?”中翻译“position”占位符。在任何情况下甚至在更新的设定部分...... :(
getSession()
.createQuery("update " + AvatarDataSet.class.getName() + " set position = :pos where dbId=:avatarId")
.setParameter("pos", ds.getPosition(), Hibernate.custom(ConstPointUserType.class))
.setParameter("avatarId", ds.getPersistentId().getLongId())
.executeUpdate();
org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: AND near line 1, column 51 [update dataSets.avatar.AvatarDataSet set position = :pos where dbId=:avatarId]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
.......
修改
这是一个错误。仍未解决。 http://opensource.atlassian.com/projects/hibernate/browse/HHH-5936