当前位置:网站首页>ORM uses different data sources and different naming transformations at the same time
ORM uses different data sources and different naming transformations at the same time
2022-07-26 22:14:00 【abckingaa】
Use different data sources and different named transformation instances at the same time .
such as :mysql Use : DB<-->Java,eg: order_no<-->orderNo.
oracle Use :DB<-->Java,eg: ORDER_NO<-->orderNo.
Refer to this example
However, it is recommended to use only one naming rule . Javabean according to DB Use Bee Automatic generation
/*
* Copyright 2016-2022 the original author.All rights reserved.
* Kingstar([email protected])
* The license,see the LICENSE file.
*/
package org.teasoft.exam.bee.osql.ds;
import org.teasoft.bee.osql.SuidRich;
import org.teasoft.exam.bee.osql.entity.Orders;
import org.teasoft.honey.osql.core.HoneyConfig;
import org.teasoft.honey.osql.core.HoneyContext;
import org.teasoft.honey.osql.name.UnderScoreAndCamelName;
import org.teasoft.honey.osql.shortcut.BF;
/**
* Use different data sources and different named transformation instances at the same time .
* <br> such as :mysql Use : DB<-->Java,eg: order_no<-->orderNo.
* <br>oracle Use :DB<-->Java,eg: ORDER_NO<-->orderNo.
* <br> Refer to this example
* <br> However, it is recommended to use only one naming rule . Javabean according to DB Use Bee Automatic generation
*
* @author Kingstar
* @since 1.11
*/
public class TwoDiffDsAndName {
static {
InitDsUtil.initDS();
}
public static void main(String[] args) {
HoneyConfig.getHoneyConfig().multiDS_enable = true; // Use multiple data sources Must be set when there are multiple data sources
HoneyConfig.getHoneyConfig().multiDS_differentDbType=true; // Use multiple databases at the same time , Be sure to set
HoneyContext.setConfigRefresh(true);
// When operating mysql when
SuidRich mysqlSuidRich=getMysqlSuidRich();
// mysqlSuidRich.select(new Orders());
mysqlSuidRich.select(new Orders(),2);
// When operating sqlite when
SuidRich sqliteSuidRich=getSqliteSuidRich();
// sqliteSuidRich.select(new Orders());
sqliteSuidRich.select(new Orders(),2);
//mysql
mysqlSuidRich.select(new Orders(),2);
}
public static SuidRich getMysqlSuidRich() {
SuidRich mysqlSuidRich=BF.getSuidRich();
// Data sources can use Java Mode configuration , You can also use xml Mode configuration
// mysqlSuidRich.setDataSourceName("mysqlDsName");
mysqlSuidRich.setDataSourceName("ds1"); // This instance is on InitDsUtil.initDS(); use java Setting mode
mysqlSuidRich.setNameTranslate(new UnderScoreAndCamelName()); //DB<-->Java,eg: order_no<-->orderNo.
return mysqlSuidRich;
}
public static SuidRich getSqliteSuidRich() {
SuidRich sqliteSuidRich=BF.getSuidRich();
// Data sources can use Java Mode configuration , You can also use xml Mode configuration
// sqliteSuidRich.setDataSourceName("sqliteDsName");
sqliteSuidRich.setDataSourceName("ds2"); // This instance is on InitDsUtil.initDS(); use java Setting mode
//TODO image Oracle The rules used , Different from others , It can be used in this way .
// sqliteSuidRich.setNameTranslate(new UpperCaseUnderScoreAndCamelName()); //DB<-->Java,eg: ORDER_NO<-->orderNo.
return sqliteSuidRich;
}
}
边栏推荐
- Altium designer 22 Chinese character garbled
- 【Qt多线程之线程的等待和唤醒】
- SQL注入 Less24(二次注入)
- July training (the 26th day) - and check the collection
- My SQL is OK. Why is it still so slow? MySQL locking rules
- Unity对资源管理器操作 打开资源管理器选择文件并筛选文件
- 08.02 邻接表
- Pytorch torch. add() torch. add_ () usage
- 07 DF command
- Go --- identifiers and keywords in go language
猜你喜欢

Oppo self-developed large-scale knowledge map and its application in digital intelligence engineering

A bowl of noodles in a dream

yolov1

Unity installation failed: operation not allowed, MKDIR

JS 延迟执行window.onload

Flink 在讯飞 AI 营销业务的实时数据分析实践

小白学习MySQL - Derived Table

day07-

Let Xiaobai thoroughly understand performance tuning

Triangular wave spectrum of MATLAB excitation model
随机推荐
Excel-vba quick start (X. prompt box, inputable pop-up box)
Qt中为工程添加资源文件、给按钮添加图片
[mysql]substr usage - query the value of specific digits of a field in the table
Just one dependency to give swagger a new skin, which is simple and cool~
OPPO 自研大规模知识图谱及其在数智工程中的应用
A bowl of noodles in a dream
The principle of normal equation method and its difference from gradient descent method
iptables防止nmap扫描以及binlog实现增量备份
06 CP command
npm, npm中文文档, npm学习使用
Understanding and practice of the trend of Bank of London foreign exchange
正规方程法(Normal Equation)原理以及与梯度下降法的区别
Oppo self-developed large-scale knowledge map and its application in digital intelligence engineering
Excel-vba quick start (XI. Common string operations)
光源控制器拨码开关使用说明
When deploying Flink on a single machine and creating the connection table of oracle19c RAC, the error ora-12505 is reported. Who can help
Actual authority comes from information superiority
Matlab draws short-term average amplitude spectrum
Go -- go language naming specification
Knowledge base tools | wechat, document center, image display page can be generated by dragging (with template, directly used)