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

mshafrir picture mshafrir · Feb 25, 2010 · Viewed 11.6k times · Source

Is it still 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 doesn't seem to do it. Any thoughts?

Answer

Pascal Thivent picture Pascal Thivent · Feb 25, 2010

It seems some people didn't read my answer correctly so I'll rephrase: your hibernate.properties looks correct, the property is well defined, it should work. So, sorry for the question but is CGlib on the classpath?

Update: Just tested and it works for me. Here is the output I get at initialization time:

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: Note that CGLIB support has been deprecated recently (this doesn't mean you won't be able to use CGLIB but the integration it not maintained anymore).