程序块Session&nbspsession&nbsp=&nbspn...
发布于 2022-03-03 16:39:25
程序块
Session session = null
try {
session = SessionContext.currentSession()
session.beginTrans()
//do something to db
session.commitTrans()
} catch (Exception ex) {
//deal exception
if (session != null)
session.releaseTrans()
}
}可以正确控制数据库事务
Session session = null
try {
session = SessionContext.currentSession()
session.beginTrans()
//do something to db
session.commitTrans()
} catch (Exception ex) {
//deal exception
if (session != null)
session.releaseTrans()
}
}可以正确控制数据库事务
登录后免费查看答案
关注者
0
被浏览
2