我有一些休眠代码,我希望我的代码在 1 个事务中运行让我在代码中解释
public void changeBranch(Branch branch) throws DatabaseException {
//some code
humanDao.update(he);
superBranchUsername = branch.getFatherUsername();
int superBranchId = branchDao.getBranchIdByUserName(superBranchUsername);
BranchEntity superBranch = branchDao.load(superBranchId);
BranchEntity be = new BranchEntity();
setBranchEntity(be, he, pkId, bname, confirmed, level, studentCount, uname, superBranch);
branchDao.update(be); // update kardane jadvale Branch va Set kardane Human motenazer be on
//some code
}
两者都 humanDao.update(he);
运行branchDao.update(be);
在 My GenericDAO 的事务句柄中,humanDao 和 branchDao 都继承自它。但我希望这段代码(上面写的)也能在事务中运行!!我怎样才能让 Hibernate 做到这一点?