Recently my task involved enabling hibernate reflection optimization in our application.
Versions used:
hibernate-core-3.3.1.GA
javassist-3.4.GA
I have collected some ideas/comments during this work and I hope they will help to improve the product.
1. I think this was already pointed out, but Hibernate documentation still misguides people to use the no-longer supported
hibernate.cglib.use_reflection_optimizer property in
Table 3.7. Miscellaneous Properties. The real name for the property is:
hibernate.bytecode.use_reflection_optimizer.
2. I have noticed that org.hibernate.bytecode.javassist.BulkAccessorFactory.findAccessors(...) is searching for accessor methods in the optimized entity class only. This means that the methods from the superclasses are not visible during BulkAccessor creation unless overridden by child classes. By enhancing the algorithm to search down the inheritance tree we could avoid creation of redundant methods which increase the code verbosity a lot. In our case almost all the entities are inherited from the base classes having the common entity properties defined, so the reflection optimization does not work for any of them until we override the inherited methods in all the child classes. The implementation is trivial, but I have got a ready prototype if anybody is interested.
3. It seems that it should be also fairly easy to optimize the EntityTuplizer's getPropertyValue and setPropertyValue calls in the similar way how the getPropertyValue
s and setPropertyValue
s are currently optimized.
Since I am a newcomer I would like to ask what is the most efficient way to make these changes be implemented in the future releases of Hibernate?