Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjs-bd-common
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
s_guodong
gjjs-bd-common
Commits
56ef0c88
Commit
56ef0c88
authored
Jan 11, 2023
by
lei wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
多数据源适配:部分代码
parent
0241dac4
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
587 additions
and
1 deletions
+587
-1
pom.xml
gjjs-bd-business/pom.xml
+5
-0
MyBatisDaoSession.java
...com/brilliance/mda/support/mybatis/MyBatisDaoSession.java
+396
-0
DbExecuteMapper.java
...ance/mda/support/mybatis/dync/mapper/DbExecuteMapper.java
+38
-0
DataSourceConfiguration.java
...java/com/ceb/gjjs/mda/config/DataSourceConfiguration.java
+45
-0
DataSourceConfiguration2.java
...ava/com/ceb/gjjs/mda/config/DataSourceConfiguration2.java
+54
-0
countermapper.xml
...ess/src/main/resources/META-INF/orm/mda/countermapper.xml
+25
-0
dbexecutemapper.xml
...s/src/main/resources/META-INF/orm/mda/dbexecutemapper.xml
+17
-0
application-oracle.yml
gjjs-bd-business/src/main/resources/application-oracle.yml
+6
-0
pom.xml
pom.xml
+1
-1
No files found.
gjjs-bd-business/pom.xml
View file @
56ef0c88
...
...
@@ -128,6 +128,11 @@
<artifactId>
ojdbc6
</artifactId>
<version>
12.1.0.2
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.30
</version>
</dependency>
</dependencies>
...
...
gjjs-bd-business/src/main/java/com/brilliance/mda/support/mybatis/MyBatisDaoSession.java
0 → 100644
View file @
56ef0c88
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package
com
.
brilliance
.
mda
.
support
.
mybatis
;
import
com.brilliance.mda.runtime.mda.IDaoSession
;
import
com.brilliance.mda.runtime.mda.IModule
;
import
com.brilliance.mda.runtime.mda.IModuleList
;
import
com.brilliance.mda.runtime.mda.IStream
;
import
com.brilliance.mda.runtime.mda.driver.MdaDriver
;
import
com.brilliance.mda.runtime.mda.driver.MdaEnv
;
import
com.brilliance.mda.runtime.mda.impl.AbstractDaoSession
;
import
com.brilliance.mda.runtime.mda.impl.Argument
;
import
com.brilliance.mda.support.mybatis.MybatisArgumentAdapter.AdaType
;
import
com.brilliance.mda.support.mybatis.count.CounterService
;
import
com.brilliance.mda.support.mybatis.dync.mapper.DbExecuteMapper
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.io.Serializable
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Component
public
class
MyBatisDaoSession
extends
AbstractDaoSession
implements
IDaoSession
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
MyBatisDaoSession
.
class
);
private
static
ThreadLocal
<
ResultSet
>
resultLocal
=
new
ThreadLocal
();
private
static
final
String
SQLID_INSERT
=
"insert"
;
private
static
final
String
SQLID_UPDATE
=
"updateByPrimaryKey"
;
private
static
final
String
SQLID_DELETE
=
"deleteByPrimaryKey"
;
private
static
final
String
SQLID_DELBYIDS
=
"deleteByIds"
;
private
static
final
String
SQLID_DYNCREAD
=
"dyncRead"
;
private
static
final
String
SQLID_DYNCDEL
=
"dyncDelete"
;
@Autowired
CounterService
counter
;
@Autowired
DbExecuteMapper
dbExecuteMapper
;
@Autowired
@Resource
(
name
=
"sqlSessionTemplate"
)
SqlSessionTemplate
sqlSessionTemplate
;
@Autowired
@Resource
(
name
=
"sqlSessionTemplate2"
)
SqlSessionTemplate
sqlSessionTemplate2
;
private
String
namespacePackage
=
"com.ceb.gjjs.mapper"
;
private
String
sqlIdTemplate
=
"%s.%sMapper.%s"
;
public
MyBatisDaoSession
()
{
}
public
void
setNamespacePackage
(
String
namespacePackage
)
{
this
.
namespacePackage
=
namespacePackage
;
}
public
void
setSqlIdTemplate
(
String
sqlIdTemplate
)
{
this
.
sqlIdTemplate
=
sqlIdTemplate
;
}
public
int
dbCounter
(
String
seqname
)
{
return
this
.
counter
.
dbCounter
(
seqname
);
}
public
int
dbInsert
(
IModule
module
)
{
String
sqlId
=
this
.
getSqlId
(
module
.
getClass
(),
"insert"
);
return
this
.
executeUpdate
(
sqlId
,
module
);
}
public
int
dbUpdate
(
IModule
module
,
Object
v1
,
String
whereCol1
)
{
return
0
;
}
public
int
dbUpdate
(
IModule
module
,
Object
v1
,
String
whereCol1
,
Object
v2
,
String
whereCol2
)
{
return
0
;
}
public
<
T
extends
IModule
>
int
dbUpdate
(
T
module
)
{
String
sqlId
=
this
.
getSqlId
(
module
.
getClass
(),
"updateByPrimaryKey"
);
return
this
.
executeUpdate
(
sqlId
,
module
);
}
public
int
dbDelete
(
IModule
module
)
{
String
sqlId
=
this
.
getSqlId
(
module
.
getClass
(),
"deleteByPrimaryKey"
);
return
this
.
executeUpdate
(
sqlId
,
module
);
}
public
int
dbDelete
(
IModule
m
,
Argument
<?
extends
Object
>...
args
)
{
Class
clazz
=
m
.
getClass
();
MybatisArgumentAdapter
adapter
=
new
MybatisArgumentAdapter
(
AdaType
.
DELETE
,
clazz
,
args
);
return
this
.
executeUpdate
(
this
.
getSqlId
(
clazz
,
"dyncDelete"
),
adapter
.
getSqlParams
());
}
public
<
T
extends
IModule
>
int
dbDelete
(
T
module
,
Serializable
...
id
)
{
Class
<
T
>
clazz
=
(
Class
<
T
>)
module
.
getClass
();
String
sqlId
=
this
.
getSqlId
(
clazz
,
"deleteByIds"
);
return
this
.
executeUpdate
(
sqlId
,
Arrays
.
asList
(
id
));
}
public
<
T
extends
IModule
>
int
dbDelete
(
Class
<
T
>
clazz
,
Map
paramMap
)
{
throw
new
UnsupportedOperationException
(
"暂不支持该方法!"
);
}
public
int
dbDelete
(
IModule
module
,
Object
val
,
String
col
)
{
return
0
;
}
public
int
dbDelete
(
IModule
module
,
Object
val
,
String
col
,
Object
val2
,
String
col2
)
{
return
0
;
}
public
<
T
extends
IModule
>
T
dbRead
(
T
module
,
Argument
...
args
)
{
MybatisArgumentAdapter
adapter
=
new
MybatisArgumentAdapter
(
AdaType
.
SELECT
,
module
.
getClass
(),
args
);
T
entity
=
(
T
)
this
.
dyncReadOne
(
module
.
getClass
(),
adapter
);
if
(
entity
!=
null
)
{
MdaDriver
.
copyValues
(
module
,
entity
);
}
return
entity
;
}
public
<
T
extends
IModule
>
T
dbRead
(
T
module
,
Object
...
args
)
{
return
null
;
}
public
<
T
extends
IModule
>
T
dbReadNoData
(
T
module
,
Object
...
args
)
{
return
null
;
}
public
<
T
extends
IModule
>
T
dbReadByArguments
(
T
module
,
Argument
<?>...
args
)
{
return
null
;
}
public
<
T
extends
IModule
>
T
dbReadHold
(
T
module
,
Object
...
args
)
{
return
null
;
}
public
<
T
extends
IModule
>
int
dbReadSet
(
IModuleList
<
T
>
list
,
Object
...
args
)
{
return
0
;
}
public
<
T
extends
IModule
>
int
dbReadset
(
IModuleList
<
T
>
list
,
int
limitSize
,
Argument
...
args
)
{
list
.
clear
();
MybatisArgumentAdapter
adapter
=
new
MybatisArgumentAdapter
(
AdaType
.
SELECT
,
list
.
getDataClass
(),
args
);
String
temp
=
adapter
.
getSqlTemplate
();
Map
<
String
,
Object
>
params
=
adapter
.
getSqlParams
();
if
(
limitSize
==
0
)
{
List
<
T
>
resultList
=
this
.
dyncRead
(
list
.
getDataClass
(),
params
);
list
.
addAll
(
resultList
);
}
return
list
.
size
();
}
public
<
T
extends
IModule
>
int
dbReadset
(
IModuleList
<
T
>
list
,
Object
...
args
)
{
list
.
clear
();
if
(
args
instanceof
Argument
[])
{
this
.
dbReadset
(
list
,
0
,
(
Argument
[])((
Argument
[])((
Argument
[])
args
)));
}
return
list
.
size
();
}
public
<
T
extends
IModule
>
int
dbReadset
(
IModuleList
<
T
>
list
,
String
whereSql
,
Object
[]
objects
)
{
list
.
clear
();
MybatisArgumentAdapter
adapter
=
new
MybatisArgumentAdapter
(
AdaType
.
SELECT
,
list
.
getDataClass
(),
whereSql
,
objects
);
List
<
T
>
result
=
this
.
dyncRead
(
list
.
getDataClass
(),
adapter
);
list
.
addAll
(
result
);
return
list
.
size
();
}
public
<
T
extends
IModule
>
int
dbReadset
(
IModuleList
<
T
>[]
lists
,
int
maxSize
,
String
whereClause
,
Object
[]
datas
)
{
List
<
Class
<?
extends
IModule
>>
clazzList
=
new
ArrayList
();
IModuleList
[]
var6
=
lists
;
int
var7
=
lists
.
length
;
int
var8
;
for
(
var8
=
0
;
var8
<
var7
;
++
var8
)
{
IModuleList
iModule
=
var6
[
var8
];
clazzList
.
add
(
iModule
.
getDataClass
());
}
MybatisArgumentAdapter
adapter
=
new
MybatisArgumentAdapter
(
AdaType
.
SELECT
,
clazzList
,
whereClause
,
datas
);
IModuleList
[]
var13
=
lists
;
var8
=
lists
.
length
;
for
(
int
var14
=
0
;
var14
<
var8
;
++
var14
)
{
IModuleList
iModule
=
var13
[
var14
];
List
<
T
>
result
=
this
.
dyncRead
(
iModule
.
getDataClass
(),
adapter
);
iModule
.
addAll
(
result
);
}
return
lists
[
0
].
size
();
}
public
void
dbReadset
(
IModuleList
[]
lists
,
String
whereClause
,
Object
[]
datas
)
{
}
public
void
dbReadset
(
IModuleList
list
,
int
maxSize
,
String
sql
)
{
}
/** @deprecated */
@Deprecated
public
<
T
extends
IModule
>
int
dbReadset
(
IModuleList
<
T
>
list
,
String
whereSql
)
{
return
this
.
dbReadset
((
IModuleList
)
list
,
whereSql
,
(
Object
[])
null
);
}
public
<
T
extends
IModule
>
int
dbReadSetByArguments
(
IModuleList
<
T
>
list
,
Argument
<?>...
args
)
{
return
0
;
}
public
void
dbConnect
()
{
this
.
sqlSessionTemplate
.
getSqlSessionFactory
().
openSession
(
false
);
}
public
void
dbDisconnect
()
{
try
{
this
.
sqlSessionTemplate
.
getConnection
().
close
();
}
catch
(
SQLException
var2
)
{
var2
.
printStackTrace
();
}
}
public
void
dbExecuteSQL
(
IStream
stm
)
{
}
public
void
dbExecuteSQL
(
IStream
sql
,
IStream
retstream
)
{
}
public
String
dbName
()
{
return
this
.
sqlSessionTemplate
.
getConfiguration
().
getDatabaseId
();
}
public
void
dbExecuteSQL
(
String
sql
,
Object
...
objects
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
();
if
(
objects
!=
null
)
{
sql
=
MybatisArgumentAdapter
.
convertPlaceHolder
(
sql
,
objects
,
map
);
}
map
.
put
(
"sql"
,
sql
);
if
(
sql
.
toUpperCase
().
startsWith
(
"SELECT"
))
{
List
<
Map
<
String
,
Object
>>
result
=
this
.
dbExecuteMapper
.
dyncReadForMap
(
map
);
if
(
result
==
null
||
result
.
size
()
==
0
)
{
this
.
setNoMoreRow
();
return
;
}
resultLocal
.
set
(
new
ResultSet
(
result
));
}
else
{
this
.
dbExecuteMapper
.
dyncUpdateForMap
(
map
);
}
}
public
void
dbFetch
(
IModule
module
)
{
}
public
void
dbFetchStream
(
IStream
args
)
{
}
public
void
dbFetchFields
(
Object
...
arguments
)
{
if
(
arguments
!=
null
&&
arguments
.
length
!=
0
)
{
if
(
resultLocal
.
get
()
==
null
)
{
log
.
error
(
"must execute dbExecuteSQL first !"
);
this
.
setNoMoreRow
();
}
else
if
(!((
ResultSet
)
resultLocal
.
get
()).
hasNext
())
{
this
.
setNoMoreRow
();
}
else
{
Map
<
String
,
Object
>
row
=
((
ResultSet
)
resultLocal
.
get
()).
next
();
Object
[]
var3
=
arguments
;
int
var4
=
arguments
.
length
;
for
(
int
var5
=
0
;
var5
<
var4
;
++
var5
)
{
Object
o
=
var3
[
var5
];
if
(
o
instanceof
Argument
)
{
Argument
argument
=
(
Argument
)
o
;
this
.
setArgumentValue
(
argument
,
row
.
get
(
argument
.
getFieldName
().
toUpperCase
()));
}
}
}
}
}
public
void
dbFetchFields
(
Argument
<?>...
arguments
)
{
}
private
void
setArgumentValue
(
Argument
<
Object
>
argument
,
Object
obj
)
{
if
(
obj
!=
null
)
{
argument
.
value
=
obj
;
}
}
public
void
dbCloseCursor
()
{
}
public
String
dbSqlDate
(
Date
endDat
)
{
return
null
;
}
public
void
dbFreeAll
()
{
}
public
void
setWaitCursor
()
{
}
public
void
dbHold
(
IModule
module
)
{
}
public
void
dbFree
(
IModule
module
)
{
}
public
void
dbSelect
(
IModule
module
,
String
string
,
String
sql
,
Object
...
val
)
{
}
public
void
DBOpen
(
IModule
module
)
{
}
public
void
dbSelectCursor
(
IModule
module
,
String
whereSql
,
Object
...
params
)
{
}
public
void
putDao
(
Class
<?>
key
,
Object
dao
)
{
throw
new
UnsupportedOperationException
(
"不支持的方法!"
);
}
private
<
T
>
String
getSqlId
(
Class
<
T
>
clazz
,
String
sid
)
{
return
String
.
format
(
this
.
sqlIdTemplate
,
this
.
namespacePackage
,
clazz
.
getSimpleName
(),
sid
);
}
private
<
T
>
T
dyncReadOne
(
Class
<?
extends
IModule
>
clazz
,
MybatisArgumentAdapter
adapter
)
{
String
sqlId
=
this
.
getSqlId
(
clazz
,
"dyncRead"
);
T
entity
=
this
.
sqlSessionTemplate
.
selectOne
(
sqlId
,
adapter
.
getSqlParams
());
if
(
entity
==
null
)
{
this
.
setNoMoreRow
();
}
return
entity
;
}
private
<
T
>
List
<
T
>
dyncRead
(
Class
<
T
>
clazz
,
MybatisArgumentAdapter
adapter
)
{
String
sqlId
=
this
.
getSqlId
(
clazz
,
"dyncRead"
);
List
<
T
>
list
=
this
.
sqlSessionTemplate
.
selectList
(
sqlId
,
adapter
.
getSqlParams
());
if
(
list
==
null
||
list
.
size
()
==
0
)
{
this
.
setNoMoreRow
();
}
return
new
ArrayList
(
list
);
}
private
<
T
>
List
<
T
>
dyncRead
(
Class
<
T
>
clazz
,
Map
params
)
{
String
sqlId
=
this
.
getSqlId
(
clazz
,
"dyncRead"
);
List
<
T
>
list
=
this
.
sqlSessionTemplate
.
selectList
(
sqlId
,
params
);
if
(
list
==
null
||
list
.
size
()
==
0
)
{
this
.
setNoMoreRow
();
}
return
new
ArrayList
(
list
);
}
private
void
setNoMoreRow
()
{
MdaEnv
.
getContext
().
setErrorCode
(
228
);
}
private
int
executeUpdate
(
String
mybatisSqlId
,
Object
params
)
{
int
cnt
=
this
.
sqlSessionTemplate
.
update
(
mybatisSqlId
,
params
);
return
cnt
;
}
public
static
class
ResultSet
{
private
int
index
=
0
;
private
List
<
Map
<
String
,
Object
>>
data
;
public
ResultSet
(
List
<
Map
<
String
,
Object
>>
data
)
{
this
.
data
=
data
;
}
public
Map
<
String
,
Object
>
next
()
{
return
this
.
index
<
this
.
data
.
size
()
?
(
Map
)
this
.
data
.
get
(
this
.
index
++)
:
null
;
}
public
boolean
hasNext
()
{
return
this
.
data
!=
null
&&
this
.
index
<
this
.
data
.
size
();
}
}
}
gjjs-bd-business/src/main/java/com/brilliance/mda/support/mybatis/dync/mapper/DbExecuteMapper.java
0 → 100644
View file @
56ef0c88
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
dync
.
mapper
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Map
;
@Component
public
class
DbExecuteMapper
{
@Autowired
@Resource
(
name
=
"sqlSessionTemplate"
)
SqlSessionTemplate
sqlSessionTemplate
;
@Autowired
@Resource
(
name
=
"sqlSessionTemplate2"
)
SqlSessionTemplate
sqlSessionTemplate2
;
final
String
FNAME
=
this
.
getClass
().
getName
();
public
DbExecuteMapper
()
{
}
public
List
<
Map
<
String
,
Object
>>
dyncReadForMap
(
Map
<
String
,
Object
>
params
)
{
return
this
.
sqlSessionTemplate
.
selectList
(
this
.
FNAME
+
".dyncReadForMap"
,
params
);
}
public
int
dyncUpdateForMap
(
Map
<
String
,
Object
>
params
)
{
return
this
.
sqlSessionTemplate
.
update
(
this
.
FNAME
+
".dyncUpdateForMap"
,
params
);
}
}
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/config/DataSourceConfiguration.java
0 → 100644
View file @
56ef0c88
package
com
.
ceb
.
gjjs
.
mda
.
config
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.mybatis.spring.SqlSessionFactoryBean
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.core.io.support.PathMatchingResourcePatternResolver
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
@Configuration
@MapperScan
(
basePackages
=
"com.ceb.gjjs.mda.dao"
,
sqlSessionTemplateRef
=
"sqlSessionTemplate"
)
public
class
DataSourceConfiguration
{
@Primary
@Bean
(
name
=
"dataSource"
)
@ConfigurationProperties
(
prefix
=
"spring.datasource.druid"
)
public
DataSource
getDataSource
()
throws
SQLException
{
return
new
DruidDataSource
();
}
@Bean
(
name
=
"sqlSessionFactory"
)
public
SqlSessionFactory
getSqlSessionFactory
(
@Qualifier
(
"dataSource"
)
DataSource
dataSource
)
throws
Exception
{
SqlSessionFactoryBean
sqlfb
=
new
SqlSessionFactoryBean
();
sqlfb
.
setDataSource
(
dataSource
);
// sqlfb.setConfigLocation(new ClassPathResource("mybatis-config.xml"));
sqlfb
.
setMapperLocations
(
new
PathMatchingResourcePatternResolver
().
getResources
(
"classpath:META-INF/orm/mda/*.xml"
));
return
sqlfb
.
getObject
();
}
@Bean
(
name
=
"transactionManager"
)
public
DataSourceTransactionManager
getTransactionManager
(
@Qualifier
(
"dataSource"
)
DataSource
dataSource
)
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
@Bean
(
name
=
"sqlSessionTemplate"
)
public
SqlSessionTemplate
getSqlSessionTemplate
(
@Qualifier
(
"sqlSessionFactory"
)
SqlSessionFactory
sqlSessionFactory
)
throws
Exception
{
return
new
SqlSessionTemplate
(
sqlSessionFactory
);
}
}
\ No newline at end of file
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/config/DataSourceConfiguration2.java
0 → 100644
View file @
56ef0c88
package
com
.
ceb
.
gjjs
.
mda
.
config
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.mybatis.spring.SqlSessionFactoryBean
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.core.io.support.PathMatchingResourcePatternResolver
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
@Configuration
@MapperScan
(
basePackages
=
"com.ceb.gjjs.mda.dao"
,
sqlSessionTemplateRef
=
"sqlSessionTemplate2"
)
public
class
DataSourceConfiguration2
{
@Bean
(
name
=
"dataSource2"
)
@ConfigurationProperties
(
prefix
=
"spring.datasource2"
)
public
DataSource
getDataSource
()
throws
SQLException
{
return
new
DruidDataSource
();
}
@Bean
(
name
=
"sqlSessionFactory2"
)
@Primary
public
SqlSessionFactory
getSqlSessionFactory
(
@Qualifier
(
"dataSource2"
)
DataSource
dataSource
)
throws
Exception
{
SqlSessionFactoryBean
sqlfb
=
new
SqlSessionFactoryBean
();
sqlfb
.
setDataSource
(
dataSource
);
// sqlfb.setConfigLocation(new ClassPathResource("mybatis-config.xml"));
sqlfb
.
setMapperLocations
(
new
PathMatchingResourcePatternResolver
().
getResources
(
"classpath:META-INF/orm/mda/*.xml"
));
return
sqlfb
.
getObject
();
}
@Bean
(
name
=
"transactionManager2"
)
@Primary
public
DataSourceTransactionManager
getTransactionManager
(
@Qualifier
(
"dataSource2"
)
DataSource
dataSource
)
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
@Bean
(
name
=
"sqlSessionTemplate2"
)
@Primary
public
SqlSessionTemplate
getSqlSessionTemplate
(
@Qualifier
(
"sqlSessionFactory2"
)
SqlSessionFactory
sqlSessionFactory
)
throws
Exception
{
return
new
SqlSessionTemplate
(
sqlSessionFactory
);
}
}
\ No newline at end of file
gjjs-bd-business/src/main/resources/META-INF/orm/mda/countermapper.xml
0 → 100644
View file @
56ef0c88
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.brilliance.mda.support.mybatis.count.mapper.CounterMapper"
>
<insert
id=
"insertNewCounter"
>
insert into COU(COUNAM,COUVAL,COUSTP) values(#{nam},#{start},#{stp})
</insert>
<select
id=
"getCountValWithUpdate"
resultType=
"java.lang.Integer"
>
select COUVAL from COU where COUNAM = #{nam} for update
</select>
<update
id=
"updateCounter"
>
update COU set COUVAL = COUVAL + COUSTP where COUNAM = #{nam}
</update>
<select
id=
"seqNextval"
resultType=
"java.lang.Integer"
>
select ${value}.nextval from dual
</select>
<select
id=
"dbCounter"
resultType=
"java.lang.Integer"
>
select f_dbcounter(#{seqName}) from dual;
</select>
</mapper>
\ No newline at end of file
gjjs-bd-business/src/main/resources/META-INF/orm/mda/dbexecutemapper.xml
0 → 100644
View file @
56ef0c88
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.brilliance.mda.support.mybatis.dync.mapper.DbExecuteMapper"
>
<select
id=
"dyncReadForMap"
resultType=
"java.util.LinkedHashMap"
>
${sql}
</select>
<update
id=
"dyncUpdateForMap"
>
${sql}
</update>
<select
id=
"dbDate"
resultType=
"java.util.Date"
>
select sysdate from dual
</select>
</mapper>
\ No newline at end of file
gjjs-bd-business/src/main/resources/application-oracle.yml
View file @
56ef0c88
...
...
@@ -44,6 +44,12 @@ spring:
port
:
6379
password
:
datasource2
:
url
:
jdbc:mysql://localhost:3306/cfix?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false
username
:
root
password
:
123456
driver-class-name
:
com.mysql.cj.jdbc.Driver
envConfig
:
rootPath
:
workRoot
...
...
pom.xml
View file @
56ef0c88
...
...
@@ -32,7 +32,7 @@
<itext-asian.version>
5.2.0
</itext-asian.version>
<xmlworker.version>
5.5.8
</xmlworker.version>
<mybatis.spring.boot.starter.version>
2.1.4
</mybatis.spring.boot.starter.version>
<mysql.connector.java.version>
5.1
.29
</mysql.connector.java.version>
<mysql.connector.java.version>
8.0
.29
</mysql.connector.java.version>
<poi.ooxml.version>
4.1.0
</poi.ooxml.version>
<commons.io.version>
2.6
</commons.io.version>
<commons.codec.version>
1.10
</commons.codec.version>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment