当前位置:网站首页>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;
}
}
边栏推荐
- Concept and classification of processes
- JDBC operation and entry case of MySQL
- 正规方程法(Normal Equation)原理以及与梯度下降法的区别
- JDBC summary
- 2018 arXiv preprint | MolGAN: An implicit generative model for small molecular graphs
- xshell7个人免费下载,使用
- matlab 基音周期估计后处理
- 08 Du command
- Task04 | classification analysis
- Isilon's onefs common operation commands (I)
猜你喜欢

梦里的一碗面

知识库工具 | 微网站、文档中心、形象展示页拖拽即可生成(附模板,直接用)

Cmake compiling obs-studio-27.2.0
![[mysql]substr usage - query the value of specific digits of a field in the table](/img/d5/68658ff15f204dc97abfe7c9e6b354.png)
[mysql]substr usage - query the value of specific digits of a field in the table

开发转测试:从零开始的6年自动化之路

day07-

Just one dependency to give swagger a new skin, which is simple and cool~

Development to testing: a six-year road to automation from scratch

Implementation of MATLAB short-time autocorrelation

Also on Data Governance
随机推荐
2018 arXiv preprint | MolGAN: An implicit generative model for small molecular graphs
正规方程法(Normal Equation)原理以及与梯度下降法的区别
寻找数字零售的发展新方向,才是保证数字零售可以进入到全新发展阶段的关键
08 du 命令
Circular progress bar animation based on cashapelayer and Bezier curve
开发转测试:从零开始的6年自动化之路
Altium Designer 22 修改选中元件的层属性
Unity对资源管理器操作 打开资源管理器选择文件并筛选文件
09 expr 命令
Pytorch--Visdom使用
同花顺上面开户安全吗,开户怎么选券商
JMeter custom log and log analysis
【地平线旭日X3派试用体验】+开箱帖
matlab 画短时能量图
Difference between D and C
NPM, NPM Chinese documents, NPM learning and using
JS verify complex password
知识库工具 | 微网站、文档中心、形象展示页拖拽即可生成(附模板,直接用)
Cmake compiling obs-studio-27.2.0
Altium Designer 22 中文字符乱码