Apache-Camel SQLAendpoint-配置自定义BeanPropertyRowMapper

cygmwpex  于 2023-03-29  发布在  Apache
关注(0)|答案(1)|浏览(117)

我正在使用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,如上面的代码示例。

jv2fixgn

jv2fixgn1#

你真的有自定义org.springframework.jdbc.core.BeanPropertyRowMapper吗?
目前无法在camel-sql中进行配置。欢迎您创建一个JIRA并在PR上添加对此的支持。

相关问题