The javadoc says:
Please note that this class is designed to provide convenience rather than high performance. For best performance consider using a custom RowMapper.
How slow is it in the real world?
The javadoc says:
Please note that this class is designed to provide convenience rather than high performance. For best performance consider using a custom RowMapper.
How slow is it in the real world?
I've never benchmarked it, because I've never found it to be a particular bottleneck. A custom RowMapper that doesn't use reflection would be faster but I've never seen a hit worth worrying about in my apps. If you're doing an extremely high performance app then it might be worth looking at, but for most purposes I think the convenience is worth the negligible hit.
A look at the source code for the base class, AbstractBeanPropertyRowMapper, suggests that a lot of the reflection-style code gets cached after the first time the class is accessed via that mapper. I cannot imagine there being any real performance issues. Quick peek: http://www.java2s.com/Open-Source/Java-Document/J2EE/spring-framework-2.5/org/springframework/jdbc/core/AbstractBeanPropertyRowMapper.java.htm
Invoking methods using reflection gives you a performance hit right off the start. In this situation, you're multiplying that performance hit by the number of results coming from the database. If your data will grow and you will be querying it often, consider using the ParameterizedRowMapper instead.
In the past, I've had to back-out of using reflection-happy convenience libraries because benchmarks showed that it turned a 100ms user look up into about 3 seconds.
Custom row mapper:
186 ms (invocation count 224 (weird...))
ParameterizedBeanPropertyRowMapper:
1301 ms (invocation count 112)
On reading one row from result set, about 11 milliseconds are saved. Which means that 1 "virtual" second is saved at reading 100 records. Multiply that on the number of users and you will get the idea. ParameterizedBeanPropertyRowMapper can be used efficiently only in small apps that run on the client's machine (desktop applications).