我正在使用camel版本3.14.5,我想知道是否有一种方法(我看不到一种方法)可以在使用SqlEndpoint
时使用自定义BeanPropertyRowMapper
。
我在一个路由中使用sql端点:
.to("mySqlComponent:classpath:my_sql.sql?outputType=StreamList&outputClass=com.my.project.MyCustomMappedPojo")
查看代码,它看起来确实像是在类中硬编码的BeanPropertyRowMapper
DefaultSqlEndpoint
@SuppressWarnings("unchecked")
public ResultSetIterator queryForStreamList(Connection connection, Statement statement, ResultSet rs) throws SQLException {
if (outputClass == null) {
RowMapper rowMapper = new ColumnMapRowMapper();
return new ResultSetIterator(connection, statement, rs, rowMapper);
} else {
Class<?> outputClzz = getCamelContext().getClassResolver().resolveClass(outputClass);
RowMapper rowMapper = new BeanPropertyRowMapper(outputClzz);
return new ResultSetIterator(connection, statement, rs, rowMapper);
}
}
因此,我所追求的是一种使用自定义行Map器的方法。
最明显的方法是将其直接传递给SqlEndpoint,但没有这样的属性。
或者,我想在Spring中连接SqlComponent
时使用自定义的SqlEndpoint
,但我看到SqlComponent
使用硬编码的SqlEndpoint
(即:不允许我注入一个自定义端点),它反过来使用硬编码的BeanPropertyRowMapper,如上面的代码示例。
1条答案
按热度按时间jv2fixgn1#
你真的有自定义
org.springframework.jdbc.core.BeanPropertyRowMapper
吗?目前无法在camel-sql中进行配置。欢迎您创建一个JIRA并在PR上添加对此的支持。