Sry for my describe unclearly and thanks for your reply
My idea is that, when use multi datasources, is there any way to map one Mapper method to many Mapper XML tag with the same id
For example:
I got a mapper called UserMapper.java and its XML (UserMapper.xml)
There is a method called 'queryUserById' in this Mapper.java, and of course a '<select id="queryUserById">' in its Mapper.xml
Because I got two datasource in the same time, one is Oracle, another is PG, so the SQL syntax may be different
I need to control the request to those DB dynamically when program is in running time (use a config center or else)
e, g: first time, I got a 'queryUserById' request, it route to Oracle by default, then i changed the route switch, then it will route to PG
For the reason above, so I need a way to control this request to find a correct SQL syntax when route switch is changed
That is what I described in begin, I need to "map one Mapper method to many Mapper XML tag with the same id"
Those tags with the same id should be used dynamically when datasource changed
UserMapper.java:
public interface UserMapper {
UserInfo queryUserById();
}
----------------------------------------------------------------------------
UserMapper.xml
<!-- this sql for Oracle -->
<select id="queryUserById" > SELECT user_name FROM user_info (some Oracle Syntax) </select>
<!-- this sql for PG-->
<select id="queryUserById" > SELECT user_name FROM user_info (Some PG Syntax)</select>
-------------------------------------------------------------------------------