Question

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?

Was it helpful?

Solution

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).

OTHER TIPS

Yeah, also put

hibernate.properties 

into some source folder and remember to have the hibermate-cglib-repack in dependencies:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-cglib-repack</artifactId>
    <version>2.1_3</version>
</dependency> 

Remember that CGLIB library is not developed for about 4 years. You should do everything however to make your code working with Javassist, which is still actively maintained.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top