我有两个数据源连接DS1和DS2。我正在使用JDBC模板。我有如下的条件选择语句,它将使用两个数据源从DS1.table1和DS2.table2中进行选择。
是否可以在单个JDBC查询中连接两个模式?
searchResult = this.jdbcTemplate.query(search_query, parameterValues.toArray(new Object[parameterValues.size()]), new ManageMapper());
StringBuilder search_query = new StringBuilder();
search_query.append(...................);
.
.
.
.
stringBuilder.append(" left join schema1.table t1 on t1.emp_id = t111.emp_id ");
if (searchRequest.getOnboardStatus() != null && (searchRequest.getOnboardStatus().equals("True")) {
stringBuilder.append(" inner join schema2.table2 t2 on t2.dept_id = t222.dept_id and t222.to_dt is null");
}
@Autowired
@Qualifier(value = "jdbcDS1")
protected JdbcTemplate jdbcDS1Template;
@Autowired
@Qualifier(value = "jdbcDS2")
protected JdbcTemplate jdbcDS2Template;