在BeanPropertyRowMapper中为属性注册转换器 [英] registering converter for property in BeanPropertyRowMapper

查看:199
本文介绍了在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆