In my application i use Hibernate and Spring declarative transaction management. When i activate transactions Hibernate uses cglib which causes LazyInitializationException when i access simple properties (no lists!) in my Hibernate classes. When i disable transactions i don't get these errors.
How can i disable usage of cglib in hibernate when i use declarative transaction management?
Thanks for your help!
Some more details:
I tried these ways to disabled cglib in hibernate with no success:
I added hibernate properties to bean configuration:
Code:
<bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
...
<prop key="hibernate.bytecode.use_reflection_optimizer">false</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
...
</props>
</property>
</bean>
I used the VM parameter:
Code:
-Dhibernate.bytecode.use_reflection_optimizer=false
-Dhibernate.cglib.use_reflection_optimizer=false
I also created a hibernate.properties file in my classpath:
Code:
hibernate.bytecode.use_reflection_optimizer=false
hibernate.cglib.use_reflection_optimizer=false
There is an old related posting with no solution: forum.springsource.org/showthread.php?p=215797 (I am not allowed to post real URLs here...).
Versions:
- Spring-2.0.7
- Hibernate-3.2.6.GA
Here is my transaction configuration:
Code:
<tx:advice id="defaultTxAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="find*" read-only="true"/>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
<tx:advice id="noTxAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="*" propagation="NEVER"/>
</tx:attributes>
</tx:advice>
<aop:config proxy-target-class="false">
<aop:pointcut id="dictionaryHandlerTx" expression="execution(* com.carano.ml.handler.*HandlerImpl.*(..))" />
<aop:advisor advice-ref="defaultTxAdvice" pointcut-ref="dictionaryHandlerTx" />
</aop:config>
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="fltutf8DataSource" />
</bean>