- 5
- 0
- 约 26页
- 2017-05-08 发布于贵州
- 举报
基于hibernae-spring的数据管理
一、数据从持久化的sessio中进入数据库!
save的时候就已经把对象持久化了..在事务commit之前save之后是加到hibernate的session缓存中(也算持久化).. commit之后才把数据写到数据库.
如下语句:
public void save(TLocrecord transientInstance) {log.debug(saving TLocrecord
instance);try {Transaction
tran=getSession().beginTransaction();//获得事物getSession().save(transientInstance);mit();//提交事务log.debug(save
successful);} catch (RuntimeException re) {log.error(save failed,
re);throw re;}}
解决办法有两种:
1、
hibernate.cfg.xml
prop key=hibernate.connection.autocommittrue/prop
2、使用Spring的事务管理
bean
id=txManagerclass=org.springframework.orm.hibernate3.HibernateTransacti
原创力文档

文档评论(0)