英文:
Apache-Camel SQLEndpoint - configure a custom BeanPropertyRowMapper
问题
I'm using camel version 3.14.5 and I'm wondering if there's a way (I can't see one) where I can use a custom BeanPropertyRowMapper
when using a SqlEndpoint
.
I'm using the sql endpoint like this in a route:
.to("mySqlComponent:classpath:my_sql.sql?outputType=StreamList&outputClass=com.my.project.MyCustomMappedPojo")
Looking at the code it does look like a BeanPropertyRowMapper is hardcoded in the class
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);
}
}
So all I'm after is a way to make use of a Custom RowMapper.
The most obvious way would be to pass it to the SqlEndpoint directly, but there's no such property.
Alternatively I thought about using a custom SqlEndpoint
whilst wiring a SqlComponent
in Spring, but I see that the SqlComponent
uses a SqlEndpoint
hardcoded (i.e.: doesn't allow me to inject a custom Endpoint) which in turns uses the hardcoded BeanPropertyRowMapper as per the code sample above.
英文:
I'm using camel version 3.14.5 and I'm wondering if there's a way (I can't see one) where I can use a customBeanPropertyRowMapper
when using a SqlEndpoint
.
I'm using the sql endpoint like this in a route:
.to("mySqlComponent:classpath:my_sql.sql?outputType=StreamList&outputClass=com.my.project.MyCustomMappedPojo")
Looking at the code it does look like a BeanPropertyRowMapper is hardcoded in the class
> 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);
}
}
So all I'm after is a way to make use of a Custom RowMapper.
The most obvious way would be to pass it to the SqlEndpoint directly, but there's no such property.
Alternatively I thought about using a custom SqlEndpoint
whilst wiring a SqlComponent
in Spring, but I see that the SqlComponent
uses a SqlEndpoint
hardcoded (i.e.: doesn't allow me to inject a custom Endpoint) which in turns uses the hardcoded BeanPropertyRowMapper as per the code sample above.
答案1
得分: 1
你真的有一个自定义的org.springframework.jdbc.core.BeanPropertyRowMapper
吗?
目前在camel-sql中无法进行配置。
欢迎您创建一个JIRA并提交PR以添加对此的支持。
英文:
Do you really have a custom org.springframework.jdbc.core.BeanPropertyRowMapper
?
Its not possible to configure currently in camel-sql.
You are welcome to create a JIRA and work on a PR to add support for this.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论