HQL in 关键字查询 报出“Ljava.lang.Long; cannot be cast to java.lang.Long“异常。
传入参数
Long[]类型:userIds
Long类型:rid
Query q = getSession().createQuery("select user from User user join user.roles as role where role.id <>:ridand user.id not in( :uids)");
q.setParameter("rid",rid);
[b]q.setParameter("uids",uids);[/b]
执行此段代码错误信息如下:
[img]http://dl.iteye.com/upload/picture/pic/48391/2afe7e27-3ffb-3395-a086-1ae06ff31746.jpg[/img]
[b]解决办法:
将
q.setParameter("userIds",userIds);
换为
q.setParameterList("userIds", userIds);[/b]
传入参数
Long[]类型:userIds
Long类型:rid
Query q = getSession().createQuery("select user from User user join user.roles as role where role.id <>:ridand user.id not in( :uids)");
q.setParameter("rid",rid);
[b]q.setParameter("uids",uids);[/b]
执行此段代码错误信息如下:
[img]http://dl.iteye.com/upload/picture/pic/48391/2afe7e27-3ffb-3395-a086-1ae06ff31746.jpg[/img]
[b]解决办法:
将
q.setParameter("userIds",userIds);
换为
q.setParameterList("userIds", userIds);[/b]