Results 1 to 3 of 3

Thread: HibernateInterceptor vs. HibernateTxManger for an open session in BO

Threaded View

  1. #1
    Join Date
    Dec 2005
    Posts
    4

    Default HibernateInterceptor vs. HibernateTxManger for an open session in BO

    Greetings,

    We want a hibernate session to be opened in a business method to navigate through the object graph. Is it better to use HibernateTransactionManger to methods that need the session but performs no transactions ( most of our business methods just need to traverse object graph ) or to use HibernateInterceptor. From the documentation for HibernateInterceptor, we are not able to find a way to specify methods that need an open session. A session seems to be created for all business methods when using HibernateInterceptor.

    Here's our HibernateTransactionManager code..

    <bean id="aclHibernateTransactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
    <property name="sessionFactory">
    <ref local="aclHibernateSessionFactory" />
    </property>
    </bean>

    <bean id="aclTxTemplate" abstract="true" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref bean="aclHibernateTransactionManager" />
    </property>
    </bean>

    <bean id="aclBO" parent="aclTxTemplate">
    <property name="target">
    <bean class="com.icrossing.aclocal.acl.model.impl.AclBO" >
    <property name="aclDAO">
    <ref bean="aclDAO" />
    </property>
    </bean>
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="getAclInfoForAllArea">PROPAGATION_REQUIRED</prop>
    </props>
    </property>
    </bean>

    And our HibernateInterceptor..

    <bean id="aclHibernateInterceptor" class="org.springframework.orm.hibernate3.Hibernat eInterceptor">
    <property name="sessionFactory">
    <ref bean="aclHibernateSessionFactory"/>
    </property>
    </bean>

    <bean id="aclBO" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="target">
    <ref bean="aclBOTarget" />
    </property>
    <property name="proxyInterfaces">
    <value>com.icrossing.aclocal.acl.model.interfaces. IAclBO</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>aclHibernateInterceptor</value>
    </list>
    </property>
    </bean>

    Please let us know.

    Thanks,
    Bagath.
    Last edited by Bagath; Dec 16th, 2005 at 04:16 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
  •