java - Not able to typecast from object to class: -
i not able typecast object variable class type variable. getting following error:
*hibernate: select osinfo0_.host_id host_id1_17_0_, osinfo0_.os_build os_build2_17_0_, osinfo0_.os_name os_name3_17_0_, osinfo0_.os_type os_type4_17_0_, osinfo0_.os_version os_versi5_17_0_ hwi.os_info osinfo0_ osinfo0_.host_id=? jun 15, 2015 10:28:20 org.apache.catalina.core.standardwrappervalve invoke severe: servlet.service() servlet [spring] in context path [/hardwareinventory] threw exception [request processing failed; nested exception java.lang.classcastexception: [ljava.lang.object; cannot cast com.vmware.hwi.model.storageinfo] root cause java.lang.classcastexception: [ljava.lang.object; cannot cast com.vmware.hwi.model.storageinfo @ com.vmware.hwi.dao.impl.storageinfodaoimpl.getstorageinfofulllistbyteam(storageinfodaoimpl.java:76) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:317) @ org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation.java:190) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:157)*
i novice hibernate query writing, doubt there might mistake in writing query, can see values returned query fine, not sure missing here.
here part of code:
@override public storageinfo getstorageinfofulllistbyteam(integer storageteam){ storageinfo storagefulllist = null; session session = sessionfactory.getcurrentsession(); /*query query = session.createquery( "from host host, storageinfo storage serverstorage" + " server storage.storageid=server.storageid" + " , server.hostid=host.hostid , storage.storageteam= ' " + storageteam+ " ' ");*/ query query = session.createquery( "from host host, storageinfo storage , serverstorage" + " server storage.storageid=server.storageid" + " , server.hostid=host.hostid , storage.storageteam= ' " + storageteam + " ' "); list info = query.list(); if(info.size() !=0){ storagefulllist = (storageinfo) info.get(0); } return storagefulllist; }
from query looks fetching host , storageinfo , serverstorage , while getting object (storageinfo) info.get(0) trying cast storageinfo. try removing host , serverstorage query or else if want fetch records 3 tables create java pojo class represents kind of columns you're fetching in query , map pojo class(try searching mapping pojo hibernate query results).
Comments
Post a Comment