Announcement Announcement Module
Collapse
No announcement yet.
org.hibernate.LazyInitializationException Again and Please Help Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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>

    Comment

    Working...
    X