如何在业务逻辑层管理事务
我想知道如何在业务逻辑层(BLL)中管理事务。
我搜索了这个网站以找到我的问题的答案,但没有成功。
我想在我的 Web 应用程序中使用 hibernate 和 struts。
在struts的Actions中,我调用了BLL函数。
在 BLL 函数中,我想要这样:
Begin transaction
try {
Call DAL to do something
...
Call DAL to do something
Commit Transaction
catch {
Roleback Transaction
}
在 DAL 中,我使用休眠函数来执行操作。
但我不知道如何在 BLL 管理交易。
请给任何建议。
谢谢。
I want to know how to manage transaction in business logic layer(BLL).
I've searched this site to find the answer to my question but didn't success.
I want to use hibernate and struts in my web application.
In Actions of struts, I call the BLL functions.
In BLL function, I want like this :
Begin transaction
try {
Call DAL to do something
...
Call DAL to do something
Commit Transaction
catch {
Roleback Transaction
}
In DAL, I use hibernate functions to do an action.
But I cannot find out how to manage the transaction at BLL.
Please give any advice.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最常见的做法是添加事务管理以及连接管理作为一个方面。如果您使用Spring,可能就像@Transactional注释您的服务的相应方法一样简单(您的业务逻辑包含在服务中,对吧?)。
The most common practice is to add transaction management, along with the connection management, as an aspect. If you are using Spring, it might be as simple as annotating corresponding methods of your services (your business logic is contained in services, right?) as @Transactional.