Announcement Announcement Module
Collapse
No announcement yet.
LazyInitializationException when setting property of Associated Object Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • LazyInitializationException when setting property of Associated Object

    I am getting LazyInitializationException when setting property of Associated Object.
    Here is the pojo
    Code:
    public class Device {
         private NamsAsset namsAsset;
    }
    
    public class NamsAsset  implements java.io.Serializable {
         private String assetId;
    }
    Here is the JSF backing bean
    Code:
    public void update(){
    Device device;
    device.getNamsAsset().setassetId(""); throws Lazy Initialization Exception
    }
    I have Transaction Management setup as
    Code:
    <bean id="txProxyTemplate" abstract="true"
            class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
            <property name="transactionManager">  <ref bean="transactionManager"/>   </property>
            
            <!-- Define Transaction Boundary at Service Layer -->
            <property name="transactionAttributes">
                <props>
                    <prop key="create*">PROPAGATION_REQUIRED</prop>                
                    <prop key="update*">PROPAGATION_REQUIRED</prop>
                    <prop key="delete*">PROPAGATION_REQUIRED</prop>                 
                    <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
                    <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
                    <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
                    <prop key="*">PROPAGATION_REQUIRED</prop>
                    <prop key="createDeviceType">PROPAGATION_REQUIRED,-com.boeing.nmt.nams.service.exception.DetachEntityException</prop>
                </props>
            </property>
    
            <property name="preInterceptors">
                <list>
    				<ref bean="hibernateInterceptor"/>
                </list>
            </property>
    
            <property name="postInterceptors">
                <list>
    
                </list>
            </property>
        </bean>
        
    	<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
    		<property name="sessionFactory" ref="sessionFactory"/>
    	</bean>
    
    
    <bean id="deviceManager" parent="txProxyTemplate" >
        	<property name="proxyInterfaces">
        		<value>com.boeing.nmt.nams.service.DeviceManager</value>
        	</property>
        	<property name="target">
        		<bean class="com.xx.impl.DeviceManagerImpl">
    		    	<property name="deviceDao" ref="deviceDao"/>
    		    	<property name="assetDao" ref="assetDao"/>
    				<property name="assetMgmtSystemDao" ref="assetMgmtSystemDao"/>
    				<property name="namsAssetDao" ref="namsAssetDao"/>
    				    </bean>
        		
        	</property>
        </bean>
    Any pointers/suggestions will be highly appreciated

  • #2
    It would be useful to see the stacktrace. I would presume however the Session has already been closed and the association wasn't eagerly loaded. Hence when Hibernate tries to lazy load the association and the Session has been closed it throws an exception.
    Last edited by karldmoore; Aug 27th, 2007, 04:01 PM.

    Comment

    Working...
    X