HQL in keyword query reported "Ljava.lang.Long; Cannot is cast to Java.lang.Long "exception.
Incoming parameters
Long[] Type: userids
Long type: 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);
q.setparameter ("UIDs", UIDs);
The error message for executing this code is as follows:
650) this.width=650; "class=" Magplus "title=" click to view original size picture "src=" http://dl.iteye.com/upload/picture/pic/48391/ 2afe7e27-3ffb-3395-a086-1ae06ff31746.jpg "width=" "height=" 229 "alt=" 2afe7e27-3ffb-3395-a086-1ae06ff31746.jpg " />
Workaround:
Will
Q.setparameter ("UserIDs", UserIDs);
Change to
Q.setparameterlist ("UserIDs", userids);
This article is from the "developer_road" blog, make sure to keep this source http://jiangdf.blog.51cto.com/6425070/1575007
Exception collation-HQL in keyword query reported "Ljava.lang.Long; Cannot is cast to Java.lang.Long "exception