Am using hibernate with struts. I wrote two ActionForms and for each ActionForm I wrote two .hbm.xml files they are LoginActionForm.hbm.xml & MailActionForm.hbm.xml. My code is shown below.
Code:
public boolean validateEmail(String userid,String email){
System.out.println("AM IN HIBERDAO CLASS");
Session session=connectHibernate();
Transaction tran=session.beginTransaction();
System.out.println("Iteration started****************Email");
Query query=session.createQuery("from LoginActionForm");
System.out.println("Iteration started****************Email");
Iterator queryitr=query.iterate();
boolean status=false;
System.out.println("EMAIL TO ITERATE*********************");
while(queryitr.hasNext()){
MailActionForm maf=(MailActionForm)queryitr.next();
if(userid.equals(maf.getUserid()) && email.equals(maf.getEmail())){
status=true;
break;} else
status=false;
} System.out.println("Iteration complete****************Email");
disconnectHibernate(session,tran);
return status;
}
I got the following error
Code:
java.lang.ClassCastException: com.miracle.forms.LoginActionForm$$EnhancerByCGLIB$$bb49811c
com.miracle.hibernate.HiberConnect.validateEmail(HiberConnect.java:37)
com.miracle.action.EmailAction.execute(EmailAction.java:62)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
I DONT UNDERSTAND WHAT THE ERROR ACTUALLY IS . CAN ANY BODY HELP ME