Hi ,
There error message is "java.util.AbstractList$Itr@110f98f" after i had step over to highlighted red line. This method will put in DAOHIBERNATE and it extends HibernateDaoSupport:
Code:
public Flight selectFlight(String city) {
Flight flight = null;
[color=red]List result = getHibernateTemplate().find("from flight where origin_city=?", city); [/color]getHibernateTemplate().flush();
Iterator iter = result.iterator();
while(iter.hasNext()){
flight=(Flight)iter.next();
System.out.println(flight);
}
return flight;
}
Why it cant execute the line? Is there anything done with configuration?
This method in Action class invoke the selectFlight() from DAOHIBERNATE:
Code:
Flight returnedProfile = null;
System.out.println("Access database HERE...");
try{
returnedProfile = t.selectFlight(new String(request.getParameter("origin_city")));
System.out.println("ReturnedProfile::"+returnedPro file);
}catch(Exception e){
errors.add("returnedResult_viewProfileAction", new ActionError("error.returnedResult"));
}
if (!errors.isEmpty()) {
saveErrors(request, errors);
System.out.println("Errors occur... terminate here");
forward = mapping.findForward("fail");
} else {
request.setAttribute("msg","Profile inserted successfully!" );
request.setAttribute("profile", flight);
forward = mapping.findForward("success");
}
return (forward);
}
I have this for my hibernate:
Code:
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.Hibernat eTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<property name="dataSource">
<ref bean="myDataSource"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQ LDialect</prop>
<prop key="show_sql">true</prop>
<prop key="hibernate.transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</prop>
<prop key="hibernate.generate_statistics">true</prop>
</props>
</property>
<bean id="profileDao" class="com.trytry.dao.hibernate.ProfileDaoHibernat e">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>
This is my spring-config.xml:
Code:
<beans>
<bean id="flight" class="com.trytry.model.Flight"/>
<bean name="/searchAction" class="com.trytry.actions.FlightAction">
<property name="flight">
<ref bean="flight"/>
</property>
</bean>
</beans>
Thank,
tiffany