liubao616 opened a new issue #2932: Cannot obtained Data from multiple data sources when integrating MyBatis with HitManager URL: https://github.com/apache/incubator-shardingsphere/issues/2932 **Hey !** Our company uses multi-tenant mode, each tenant corresponds to a database. Now we need to get the data of two tenants at the same time, using HitManager strong routing mode. __Here is a simulated custom HintSharing Algorithm algorithm,The code is as follows:__ ` public class MyHintShardingAlgorithm implements HintShardingAlgorithm<String>{ public Collection<String> doSharding(Collection<String> availableTargetNames, HintShardingValue<String> shardingValue) { Collection<String> result=new ArrayList<String>(); //more dataSources result.add("MD_COMMON_OA"); result.add("MD_XXZX_OA"); return result; } } ` __Data can be obtained using java. sql API,The code is as follows:__ ` public void test2() throws SQLException { HintManager hintManager=HintManager.getInstance(); hintManager.setDatabaseShardingValue("MD_XXZX_OA:MD_COMMON_OA"); String sql="SELECT * from test_table"; try (Connection connection = dataSource.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement(sql)) { preparedStatement.setString(1, "MD_XXZX_OA"); try (ResultSet resultSet = preparedStatement.executeQuery()) { int i=0; while (resultSet.next()) { System.out.print("application_code:" + resultSet.getObject(1) + ", "); } } } hintManager.close(); }` __But you can not get data using MyBatis, The code is as follows:__ ` public void test3() throws SQLException { SqlSession session= sqlSessionFactory.openSession(); HintManager hintManager=HintManager.getInstance(); hintManager.setDatabaseShardingValue("MD_XXZX_OA:MD_COMMON_OA"); List<Map<String, Object>> datas=session.selectList("getStartFlowListBySysType", "MD_XXZX_OA"); session.commit(); System.out.println(datas.size()); hintManager.close(); }` __The version I use is:4.0.0-RC3-SNAPSHOT__
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
