hibernate - java.lang.ClassCastException: [Ljava.lang.Object; -
i have 2 functions in application , after executing queries got exception
java.lang.classcastexception: [ljava.lang.object; java.lang.classcastexception: [ljava.lang.object; @ org.openmrs.module.scheduler.impl.schedulerdwr.fetchuserstatus(schedulerdwr.java:2011) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.directwebremoting.impl.executeajaxfilter.dofilter(executeajaxfilter.java:34) @ org.directwebremoting.impl.defaultremoter$1.dofilter(defaultremoter.java:428) @ org.directwebremoting.impl.defaultremoter.execute(defaultremoter.java:431) @ org.directwebremoting.impl.defaultremoter.execute(defaultremoter.java:283) @ org.directwebremoting.servlet.plaincallhandler.handle(plaincallhandler.java:52) @ org.directwebremoting.servlet.urlprocessor.handle(urlprocessor.java:101) @ org.directwebremoting.servlet.dwrservlet.dopost(dwrservlet.java:146) @ javax.servlet.http.httpservlet.service(httpservlet.java:637) @ javax.servlet.http.httpservlet.service(httpservlet.java:718) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:290) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.openmrs.web.mytimerfilter.dofilter(mytimerfilter.java:69) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:235) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.openmrs.web.filter.gzipfilter.dofilterinternal(gzipfilter.java:61) @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:76) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:235) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.openmrs.module.web.filter.modulefilterchain.dofilter(modulefilterchain.java:77) @ org.openmrs.module.web.filter.modulefilter.dofilter(modulefilter.java:59) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:235) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.openmrs.web.filter.openmrsfilter.dofilterinternal(openmrsfilter.java:112) @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:76) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:235) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.springframework.orm.hibernate3.support.opensessioninviewfilter.dofilterinternal(opensessioninviewfilter.java:198) @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:76) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:235) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.springframework.web.filter.characterencodingfilter.dofilterinternal(characterencodingfilter.java:97) @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:76) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:235) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:233) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:191) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:127) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:102) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:111) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:298) @ org.apache.coyote.http11.http11aprprocessor.process(http11aprprocessor.java:865) @ org.apache.coyote.http11.http11aprprotocol$http11connectionhandler.process(http11aprprotocol.java:579) @ org.apache.tomcat.util.net.aprendpoint$worker.run(aprendpoint.java:1555) @ java.lang.thread.run(thread.java:662)
these functions 1
public int fetchuserstatus(string provider) { try { schedulerservice hservice = (schedulerservice)context.getservice(schedulerservice.class); list<moduleuser> lst=hservice.fetchuserstatus(id); for(moduleuser m:lst)//exception in line { int userid=((moduleuser) m).getuserid(); if(userid==id) { status=((moduleuser) m).getuserstatus(); system.out.println("inside for"+status); } } system.out.println("status update"+status); return status; } catch(exception e) { e.printstacktrace(); return 2; } }
function 2
public list<moduleuser> fetchuserstatus(int id) { try { session=sessionfactory.getcurrentsession(); sqlquery m=session.createsqlquery("select * users"); return m.list(); } catch(exception e) { e.printstacktrace(); return null; } }
can suggest wrong code?
is moduleuser
mapped @entity
? if yes use hql instead of native query
list<moduleuser> users = session.createquery("from moduleuser").list()
else if forced native sql use @aim solution
Comments
Post a Comment