当前位置:网站首页>A usage example that can be compatible with various database transactions
A usage example that can be compatible with various database transactions
2022-07-05 10:38:00 【Full stack programmer webmaster】
Incoming entity execution ( Additable modify Delete ) Business .
IDbHelper dbHelper = new OracleHelper(ConfigHelper.GetConfigString("BusinessDbConnection"));
bool result = true;
try
{
dbHelper.BeginTransaction();
// Main table
TE_AREAManager manager = new TE_AREAManager(dbHelper, userInfo);
TE_AREAEntity tE_AREAEntity = manager.GetObject(dbHelper.SqlSafe(eatxtAREA_ID));
manager.Delete(tE_AREAEntity);
// Sub table
TE_AREA_SUBManager submanager = new TE_AREA_SUBManager(dbHelper, userInfo);
TE_AREA_SUBEntity tE_AREA_SUBEntity = submanager.GetObject(dbHelper.SqlSafe(eatxtAREA_ID));
submanager.Delete(tE_AREA_SUBEntity);
// Transaction submission
dbHelper.CommitTransaction();
}
catch(Exception ex)
{
// Transaction rollback
dbHelper.RollbackTransaction();
result=false;
}You can pass in sql Statements execute transactions
IDbHelper dbHelper = new OracleHelper(ConfigHelper.GetConfigString("BusinessDbConnection"));
bool result = true;
try
{
dbHelper.BeginTransaction();
string commandText = " DELETE FROM TE_AREA WHERE ID=" + dbHelper.SqlSafe(id);
dbHelper.ExecuteNonQuery(sqlString);
commandText = " DELETE FROM TE_AREA_SUB WHERE ID=" + dbHelper.SqlSafe(id);
dbHelper.ExecuteNonQuery(commandText);
dbHelper.CommitTransaction();
}
catch(Exception ex)
{
dbHelper.RollbackTransaction();
result=false;
}You can also pass in entities at the same time ,SQL sentence
IDbHelper dbHelper = new OracleHelper(ConfigHelper.GetConfigString("BusinessDbConnection"));
bool result = true;
try
{
dbHelper.BeginTransaction();
// Main table
TE_AREAManager manager = new TE_AREAManager(dbHelper, userInfo);
TE_AREAEntity tE_AREAEntity = manager.GetObject(dbHelper.SqlSafe(eatxtAREA_ID));
manager.Delete(tE_AREAEntity);
// Sub table
TE_AREA_SUBManager submanager = new TE_AREA_SUBManager(dbHelper, userInfo);
TE_AREA_SUBEntity tE_AREA_SUBEntity = submanager.GetObject(dbHelper.SqlSafe(eatxtAREA_ID));
submanager.Delete(tE_AREA_SUBEntity);
// perform SQL sentence
string commandText = " DELETE FROM JINTIANDA WHERE ID=" + dbHelper.SqlSafe(id);
dbHelper.ExecuteNonQuery(commandText);
// Transaction submission
dbHelper.CommitTransaction();
}
catch(Exception ex)
{
// Transaction rollback
dbHelper.RollbackTransaction();
result=false;
}The above transaction processing method is based on the underlying code of Jiri Gala general permission management component ,dbHelper, Compatible with all kinds of data Library transactions , It's very easy .
Welcome to provide your own experience , Jointly improve development efficiency .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/109843.html Link to the original text :https://javaforall.cn
边栏推荐
- [paper reading] kgat: knowledge graph attention network for recommendation
- 想请教一下,十大券商有哪些?在线开户是安全么?
- Who is the "conscience" domestic brand?
- 沟通的艺术III:看人之间 之倾听
- 到底谁才是“良心”国产品牌?
- Have you learned to make money in Dingding, enterprise micro and Feishu?
- Pseudo class elements -- before and after
- Node の MongoDB Driver
- 2022年危险化学品生产单位安全生产管理人员特种作业证考试题库模拟考试平台操作
- How do programmers live as they like?
猜你喜欢

AD20 制作 Logo

SAP UI5 ObjectPageLayout 控件使用方法分享

2022年危险化学品生产单位安全生产管理人员特种作业证考试题库模拟考试平台操作
![[observation] with the rise of the](/img/9a/8bbf98e6aed80638f4340aacec2ea9.jpg)
[observation] with the rise of the "independent station" model of cross-border e-commerce, how to seize the next dividend explosion era?

IDEA新建sprintboot项目

Universal double button or single button pop-up

csdn软件测试入门的测试基本流程

风控模型启用前的最后一道工序,80%的童鞋在这都踩坑

Events and bubbles in the applet of "wechat applet - Basics"

How to write high-quality code?
随机推荐
《通信软件开发与应用》课程结业报告
Window下线程与线程同步总结
PWA (Progressive Web App)
LSTM应用于MNIST数据集分类(与CNN做对比)
Workmanager Learning one
C function returns multiple value methods
Idea create a new sprintboot project
C语言实现QQ聊天室小项目 [完整源码]
What are the top ten securities companies? Is it safe to open an account online?
@Jsonadapter annotation usage
运算符、、
函数///
括号匹配问题(STL)
埋点111
[dark horse morning post] Luo Yonghao responded to ridicule Oriental selection; Dong Qing's husband Mi Chunlei was executed for more than 700million; Geely officially acquired Meizu; Huawei releases M
Timed disappearance pop-up
想请教一下,十大券商有哪些?在线开户是安全么?
重磅:国产IDE发布,由阿里研发,完全开源!
QT implements JSON parsing
Glide Mastery