问题:
使用myeclipse生成的dao中的save方法储存不进去数据?
解答:
Transcation的commit!!!
说明:下面代码中在原来生成的代码中没有带星号注释的行
public void save(Script transientInstance) {
log.debug("saving Script instance");
Transaction tran=getSession().beginTransaction(); //****
try {
getSession().save(transientInstance);
getSession().flush(); //***********
tran.commit(); //**********************
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
tran.rollback();
throw re;
}
本文介绍了解决 MyEclipse 生成的 DAO 层 save 方法无法存储数据的问题。通过添加事务管理和提交操作,确保数据能够成功保存到数据库中。
3623

被折叠的 条评论
为什么被折叠?



