我執行使用Hibernate選擇選項,執行查詢時,但在query.list()
方法越來越例外,如何解決java.lang.ClassCastException:爲query.list()在休眠
這裏是我的代碼,
String hql="select a.vehicleno, a.lat, a.lng, a.status, a.rdate, a.rtime from LatitudeBean a, VehicleRegisterBean b where a.vehicleno=b.vehicleno and b.clientid= :clientId and b.groupid in(select groupid from GroupDetails where groupname= :groupname and clientid= :gdclientId)"; // valid query
Query query =sessio.createQuery(hql);
List<LatitudeBean> groupList = (List<LatitudeBean>)query.list(); //Here I am getting exception
for(LatitudeBean arr : groupList){
System.out.println(arr.getVehicleno());
}
的例外是,
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.aurodisplay.its.beans.LatitudeBean
at com.abc.its.controller.LoginController.doPost(LoginController.java:83)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
如何演員名單從list()
方法返回。任何人都可以幫助我。
你的HQL是什麼? – Adi 2014-08-27 10:38:01
也發佈你的異常堆棧跟蹤。 – 2014-08-27 10:38:59
@BuhakeSindi查看我更新的問題 – Raghu 2014-08-27 10:42:00