java - Cast exception from one class to another -
session session2 = hibernateutil.getsessionfactory().opensession(); transaction tx2 = session2.begintransaction(); query q=session2.createquery("from studbean1 group sno"); list<student_change> l1=(list<student_change>)q.list(); //student_change sc=new student_change(); for(student_change sc3:l1){ session2.save(sc3); tx2.commit(); session2.close();
here data coming studbean1 can access data student_change
but gives excption can't cast studbean1
student_change
given have modelled student_change
generalisation of studbean1
, list<studbean1>
not subtype of list<student_change>
. try getting list<studbean1>
, iterating on , perform cast in loop.
why-is-liststring-not-a-subtype-of-listobject
anyway, there more problems in code should revise (see comments question).
Comments
Post a Comment