在运行以下代码段时:
String hqlSelect = "select bookID from Issued where regID = " + regID;
List list = sess.createQuery(hqlSelect).list();
Iterator i = list.iterator();
while(i.hasNext()) {
Issued issued = (Issued) i.next(); // LINE : 46
bookIdList.add(issued.getBookID());
}
行号46
生成异常。
java.lang.ClassCastException: java.lang.Long cannot be cast to pojo.Issued
在查询bookID
and regID
are 类型Long
和发出的是一个包含bookID
and的类regID
。
为什么我会收到此异常?