JDBC exception on Hibernate data access; nested exception is org.hibernate.exception.GenericJDBCException: could not initialize a collection: [com.db.tarena.crm.order.entity.Order.product#2]dao
public List getByOrderStatus(final String status) {
HibernateTemplate ht=getHibernateTemplate();
return ht.executeFind(new HibernateCallback (){ public Object doInHibernate(Session session)
throws HibernateException, SQLException {
String hql="from Order  a where a.order_Status=:status ";
List<Order> list=session.createQuery(hql).setString("status", status).list();
for(Order o:list)
{
Hibernate.initialize(o.getCustomer());
System.out.println("heheh");
Hibernate.initialize(o.getProduct());
System.out.println("hggggg");
}
return list;
}
});
}
在测试类里List<Order> list=os.queryByOrderStatus("1");

for(Order o:list)
{
Set<Product> s=o.getProduct();
for(Product product:s)
{
System.out.println(product.getProduct_Name());
}
}不会出现问题
写在Action 中 List order=os.queryByOrderStatus(value);  就报错了郁闷啊