Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 281
mshafrir Avatar asked Feb 24 '10 23:02

mshafrir


3 Answers

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

like image 69
Pascal Thivent Avatar answered Sep 20 '22 11:09

Pascal Thivent


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> 
like image 1
Martin Avatar answered Sep 21 '22 11:09

Martin


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.

like image 1
iirekm Avatar answered Sep 22 '22 11:09

iirekm