Commit 985dcfda by s_guodong

dbread如果查到多条返回一条

parent 52136545
......@@ -167,17 +167,31 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
@Override
public <T extends IModule> T dbRead(T module, Argument... args) {
// if (isMultiDb) {
// String moduleDB = MdaUtils.getModuleDB(module);
// DynamicDataSourceContextHolder.setDataSourceType(moduleDB);
// }
// MybatisArgumentAdapter adapter = new MybatisArgumentAdapter(SELECT, module.getClass(), args);
//
// T entity = this.dyncReadOne(module.getClass(), adapter);
// if (entity != null) {
// MdaDriver.copyValues(module, entity);
// }
// return entity;
if (isMultiDb) {
String moduleDB = MdaUtils.getModuleDB(module);
DynamicDataSourceContextHolder.setDataSourceType(moduleDB);
}
MybatisArgumentAdapter adapter = new MybatisArgumentAdapter(SELECT, module.getClass(), args);
T entity = this.dyncReadOne(module.getClass(), adapter);
if (entity != null) {
MdaDriver.copyValues(module, entity);
String sqlId = getSqlId(module.getClass(), SQLID_DYNCREAD);
List<T> list = sqlSessionTemplate.selectList(sqlId, adapter.getSqlParams());
if (list == null || list.size() == 0) {
setNoMoreRow();
return null;
}
return entity;
MdaDriver.copyValues(module, list.get(0));
return list.get(0);
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment