在BeanPropertyRowMapper中为属性注册转换器 [英] registering converter for property in BeanPropertyRowMapper
问题描述
我正在使用 org.springframework.jdbc.core.BeanPropertyRowMapper 将JDBC语句的结果转换为Bean,效果很好.
I am using org.springframework.jdbc.core.BeanPropertyRowMapper to convert the results of a JDBC statement into a Bean, which works well.
我只想在填充特殊的bean属性之前将结果的一个值转换为另一个值.
I just want to convert one value of the result into another value before filling a special bean property.
我创建了一个 PropertyEditor ,并尝试通过 CustomEditorConfigurer 和自定义的 PropertyEditorRegistrar 进行注册,但尝试使用 PropertyEditor BeanPropertyRowMapper填充属性时不使用>.
I created a PropertyEditor and tried to register it via the CustomEditorConfigurer and a custom PropertyEditorRegistrar, but the PropertyEditor is not used when the BeanPropertyRowMapper fills the properties.
当BeanWrapperImpl查找PropertyEditors时,找不到它,因为customEditorsForPath始终为空.
When the BeanWrapperImpl looks for PropertyEditors it does not find one because the customEditorsForPath is always empty.
使用 BeanPropertyRowMapper 时,如何为我的Bean的一个特殊属性注册PropertyEditor?
How do I get my PropertyEditor registered for that one special property of my Bean when using the BeanPropertyRowMapper?
推荐答案
您似乎需要扩展BeanPropertyRowMapper
并在覆盖的initBeanWrapper()
中注册编辑器.
It looks like you need to extend BeanPropertyRowMapper
and register your editors in overriden initBeanWrapper()
.
这篇关于在BeanPropertyRowMapper中为属性注册转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!