Isn’t the use of Java Reflection a performance hit?

The Borland EJB Container uses reflection rather than generated code to implement container-managed persistence. Evaluators have wondered if the reflection approach is much slower than the use of pre-generated code.

We too had concerns about its performance, but as long as you cache the lookups, reflection is very fast. What is slow is doing things like looking up a method on a class or looking up an instance member. We do all these lookups once and then cache the results. Subsequently, we are simply doing the assignments of CMP members or the invocation of bean methods using reflection-- and this is very fast.

Also, bear in mind that by using reflection, we can do optimizations such as "tuned writes" and "field-level diff detection" which are very hard to do with generated code.