-
Jan 5th, 2007, 10:12 AM
#1
An error terminate at getHibernateTemplate()
Hi, i had a problem with Hibernate. I have this code in DAOHIBERNATE:
public Flight selectFlight(String city) {
Flight flight = null;
List result = getHibernateTemplate().find("from flight where origin_city=?", city); getHibernateTemplate().flush();
Iterator iter = result.iterator();
while(iter.hasNext()){
flight=(Flight)iter.next();
System.out.println(flight);
}
return flight;
}
Whenever i step over the hightlighted red line, an error will occured. They didnt prompt me exception but it println out my error msg in the console.
Can anybody help me with it? Why it cant execute the line? Is there anything done with configuration? I have this for my hibernate:
<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 method in Action class invoke the selectFlight() from DAOHIBERNATE:
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);
}
Regards,
tiffany
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules