Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
662 views
in Technique[技术] by (71.8m points)

java - registering converter for property in BeanPropertyRowMapper

I am using org.springframework.jdbc.core.BeanPropertyRowMapper to convert the results of a JDBC statement into a Bean, which works well.

I just want to convert one value of the result into another value before filling a special bean property.

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.

When the BeanWrapperImpl looks for PropertyEditors it does not find one because the customEditorsForPath is always empty.

How do I get my PropertyEditor registered for that one special property of my Bean when using the BeanPropertyRowMapper?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It looks like you need to extend BeanPropertyRowMapper and register your editors in overriden initBeanWrapper().


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...