Results 1 to 5 of 5

Thread: Hibernate Lazy loading without Servlet Filter

  1. #1
    Join Date
    Oct 2004
    Location
    Germany
    Posts
    143

    Default Hibernate Lazy loading without Servlet Filter

    Hi,

    I must use the lazy loading feature from Hibernate 3 within my client application.

    I use the Spring's AOP TransactionInterceptor as described in chapter 11.2.6 at Spring Docs.

    at the spring api docs I read that lazy loading only works with a open session, but how can I use this feature without the OpenSessionIviewFilter ??

    thanks.

    mfg Gideon

  2. #2
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    You can use the OpenSessionInViewInterceptor. http://static.springframework.org/sp...terceptor.html

    It will wrap your normal beans with a hibernate session.

  3. #3
    Join Date
    Oct 2004
    Location
    Germany
    Posts
    143

    Default

    Hi,

    thank you for your hint.

    but it does not work for me, this is my configuration:
    Code:
    	<bean id="myHibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
    		<property name="sessionFactory"><ref bean="sessionFactory"/></property>
    		<property name="entityInterceptorBeanName"><value>sessionInterceptor</value></property>
        </bean> 
    
    
    	<!-- Hibernate SessionFactory -->
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<!-- property name="jtaTransactionManager"><ref bean="transactionManager"/></property-->
    		<property name="dataSource"><ref local="dataSource"/></property>		
    		<property name="mappingResources">
    			<list>
    				<value>de.mk.user.hbm.xml</value>
    				<value>de.mk.srb.model.hbm.xml</value>
    			</list>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">$&#123;hibernate.dialect&#125;</prop>
    				<prop key="hibernate.show_sql">true</prop>
    			</props>
    		</property>
    	</bean>
    	
    	<bean name="sessionInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
    		<property name="sessionFactory"><ref bean="sessionFactory"/></property>
    	</bean>
    has anyone any idee what I have maked wrong?

    thanks.

    ys Gideon

  4. #4
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    You must wrap your business beans with the interceptor. It is not enough to actually declare it:

    <bean name="myUrl.htm" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces">
    <value>org.springframework.web.servlet.mvc.Control ler</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>transactionInterceptor</value>
    <value>myActualController</value>
    </list>
    </property>
    </bean>

  5. #5
    Join Date
    Oct 2004
    Location
    Germany
    Posts
    143

    Default

    your example is for a webapplication but, I need lazy fetching without WebContent.

    is there a way to use this Interceptor inside a client application (yes the application runs inside tomcat but the beans they need lazy fetching are jobs that where fired by quartz) ?

    thanks.

    ys Gideon

Similar Threads

  1. Replies: 11
    Last Post: Jun 1st, 2006, 04:30 PM
  2. Hibernate Long Session Per Flow?
    By akw in forum Web Flow
    Replies: 21
    Last Post: Dec 12th, 2005, 08:06 PM
  3. Replies: 2
    Last Post: Dec 8th, 2005, 09:00 AM
  4. how to use hibernate lazy loading with spring transaction
    By tanmoy.chakraborty in forum Data
    Replies: 1
    Last Post: Oct 11th, 2005, 02:07 AM
  5. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM

Posting Permissions

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