How to force Hibernate 3.3 or 3.5 to use CGLib instead of Javassist?

Is it possible to force Hibernate 3.3 or 3.5 to use CGLib instead of Javassist? In my properties file I set

hibernate.bytecode.provider = cglib 

But this is not like that. Any thoughts?

+6
java orm hibernate cglib
source share
3 answers

It seems that some people have not read my answer correctly, so I will rephrase: your hibernate.properties looks right, the property is well defined, it should work. So sorry for the question, but is CGlib on the way to classes?

Update: Just tested, and it works for me. Here is the result that I get when initializing:

  15 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.0.SP1
 18 [main] INFO org.hibernate.cfg.Environment - loaded properties from resource hibernate.properties: {hibernate.bytecode.use_reflection_optimizer = false, hibernate.bytecode.provider = cglib}
 20 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name: cglib

PS: Please note that CGLIB support has recently been deprecated (this does not mean that you cannot use CGLIB, but integration is not supported anymore).

+7
source share

Yes, also put

 hibernate.properties 

to any source folder and don't forget to have hibermate-cglib-repack in the dependencies:

 <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-cglib-repack</artifactId> <version>2.1_3</version> </dependency> 
+1
source share

Remember that the CGLIB library has not been developed for about 4 years. However, you must do everything to make your code work with Javassist, which is still actively supported.

+1
source share

All Articles