Results 1 to 2 of 2

Thread: org.hibernate.LazyInitializationException Again and Please Help

  1. #1
    Join Date
    Apr 2006
    Posts
    5

    Default org.hibernate.LazyInitializationException Again and Please Help

    Hi All

    I am just learning about spring + hibernate on normal application (Swing) everything run smoothly until lazyloading problem
    here is the error
    3703 [main] ERROR org.hibernate.LazyInitializationException - failed to lazily initialize a collection of role: com.acompany.categories - no session or session was closed

    now i have trying to change my applicationContext.xml

    now like this

    <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.Hibernat eInterceptor">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>
    <bean id="maintenanceServiceTarget" class="com.acompany.MaintenanceServiceImpl">
    <property name="categoryDao"><ref bean="categoryDao" /></property>
    <property name="divisionDao"><ref bean="divisionDao" /></property>
    </bean>
    <bean id="maintenanceService" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="target">
    <ref bean="maintenanceServiceTarget" />
    </property>
    <property name="proxyInterfaces">
    <value>com.acompany.MaintenanceService</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>hibernateInterceptor</value>
    </list>
    </property>
    </bean>

    is anyone can please please help me?

    Spring + Hibernate should be extremely easy but with this lazy it is throwing more trouble that it should be

    please help

    many thanks in advance

  2. #2

    Default

    u just not using AOP correctly..read more on AOP,etc..

    Code:
        <bean id="hibernateInterceptor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
        	<property name="advice">
        		<ref bean="hibernateInterceptorAdvice"/>
        	</property>
         	<property name="patterns">
    	        <list>        
    	            <value>.*save.*</value>  
    	            <value>.*update.*</value>
    	             <value>.*something.*</value>	             
    	        </list>
    	    </property>
    	 </bean>
    	 
        <bean id="hibernateInterceptorAdvice" class="org.springframework.orm.hibernate.HibernateInterceptor">
             <property name="sessionFactory">
               <ref bean="sessionFactory"/>
             </property>
        </bean>
    /^\\ Pharaoh /^\\
    http://pharaohofkush.blogspot.com/

    Jeryl Cook

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •