Announcement Announcement Module
Collapse
No announcement yet.
Lazy Initialization again... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lazy Initialization again...

    I am having a problem getting lazy initialization to work as it is outlined at http://www.jroller.com/page/kbaum?en...ation_with_dao.

    Here are the snippets of interest here...

    appName-servlet.xml ->

    <bean id="urlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="interceptors">
    <list>
    <ref bean="openSessionInViewInterceptor"/>
    </list>
    </property>
    <property name="urlMap">
    <map>
    <entry key="/shop/shoppingWizardForm.do"><ref local="shopping_wizard"/></entry>
    <entry key="/shop/viewCategory.do"><ref local="view_category"/></entry>
    </map>
    </property>
    </bean>

    <bean name="openSessionInViewInterceptor" class="org.springframework.orm.hibernate.support.O penSessionInViewInterceptor">
    <property name="sessionFactory"><ref bean="sessionFactory"/></property>
    </bean>

    <bean id="defaultHandlerMapping" class="org.springframework.web.servlet.handler.Bea nNameUrlHandlerMapping"/>


    applicationContext.xml ->

    <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean" abstract="true">
    <property name="transactionManager"><ref bean="transactionManager"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="insert*">PROPAGATION_REQUIRED</prop>
    <prop key="update*">PROPAGATION_REQUIRED</prop>
    <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
    </props>
    </property>
    </bean>

    <bean id="wcStore" parent="baseTransactionProxy">
    <property name="target">
    <bean class="com.wasatchcottage.domain.logic.WCStoreImpl ">
    <property name="productDao"><ref bean="productDao"/></property>
    <property name="categoryDao"><ref bean="categoryDao"/></property>
    <property name="taxClassDao"><ref bean="taxClassDao"/></property>
    <property name="productOptionDao"><ref bean="productOptionDao"/></property>
    <property name="productOptionValueDao"><ref bean="productOptionValueDao"/></property>
    <property name="productAttributeDao"><ref bean="productAttributeDao"/></property>
    <property name="customerDao"><ref bean="customerDao"/></property>
    <property name="countryDao"><ref bean="countryDao"/></property>
    <property name="addressDao"><ref bean="addressDao"/></property>
    <property name="stateCodeDao"><ref bean="stateCodeDao"/></property>
    <property name="shippingCarrierDao"><ref bean="shippingCarrierDao"/></property>
    <property name="shippingMethodDao"><ref bean="shippingMethodDao"/></property>
    <property name="shippingRangeDao"><ref bean="shippingRangeDao"/></property>
    <property name="shippingRateDao"><ref bean="shippingRateDao"/></property>
    <property name="shippingZoneDao"><ref bean="shippingZoneDao"/></property>
    <property name="zoneTypeDao"><ref bean="zoneTypeDao"/></property>
    </bean>
    </property>
    <property name="proxyInterfaces">
    <value>com.wasatchcottage.domain.logic.WCStoreFaca de</value>
    </property>
    <property name="preInterceptors">
    <list>
    <ref local="hibernateInterceptor"/>
    </list>
    </property>
    </bean>

    <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate.Hibernate Interceptor">
    <property name="sessionFactory"><ref bean="sessionFactory"/></property>
    </bean>

    dataAccessContext.xml ->

    <bean id="transactionManager" class="org.springframework.orm.hibernate.Hibernate TransactionManager">
    <property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>

    Code of interest...

    ShippingCarrier shippingCarrier = shippingCarrierWebComponent.getLocalCarrier(); <- this returns the proper shipping carrier, but the method are not Lazily initialized
    Set localCarrierMethods = shippingCarrier.getMethods(); <- This line fails.

    I have debugged this and can see the HibernateInterceptor being called, but it doesn't return the lazy initialization of the methods.

    Any help would be great. I can get them to initialize by refreshing the object from the database, but don't want to have to do that every time.
Working...
X