嗨,我在用Hibernate3.0
面临数据保存的问题。
在下面的代码中,client是我要保存的pojo。尽管我试着解决同样的问题
try {
getHibernateTemplate().saveOrUpdate(client);
System.out.println("This is executed");
getHibernateTemplate().getSessionFactory().getCurrentSession().flush();
} catch (DataAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (HibernateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
获取以下异常
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574)
at com.hewitt.appinv.dao.ClientDAOImpl.saveClient(ClientDAOImpl.java:118)