问题:
使用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;
}