本文共 642 字,大约阅读时间需要 2 分钟。
Dao层代码:
public Serializable add(Object entity) {
return this.getHibernateTemplate().save(entity); }不管什么异常,只要你catch了,spring就会放弃经管。
Session session = this.getHibernateTemplate().getSessionFactory().openSession()/buildSession()/getCurrentSession();
Transaction tx = session.beginTransaction(); tx.begin(); try { for (Object o : entity){ session.save(o); } tx.commit(); } catch (Exception e) { e.printStackTrace(); tx.rollback(); } session.close();
org.springframework.web.context.ContextLoaderListener
</context-param>
本文转自农夫山泉别墅博客园博客,原文链接:http://www.cnblogs.com/yaowen/archive/2013/02/26/2933101.html,如需转载请自行联系原作者