Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7849627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:35:12+00:00 2026-06-02T18:35:12+00:00

I am using HibernateTemplate and have one abstract class where i have written all

  • 0

I am using HibernateTemplate and have one abstract class where i have written all insert,delete,update stuff. No the case is I am having a service method in which I have to make entries in two tables say tbl_StudentMaster and tbl_StudenDetail and I need to implement transaction management. I had set autocommit false in Application context and also had tried with org.springframework.transaction.interceptor.TransactionProxyFactoryBean class but I am still not able to achieve transaction. And In my MVC controller I am injecting StudentService.

<bean class="org.apache.commons.dbcp.BasicDataSource" id="dataSource" destroy-method="close" >
    <property name="driverClassName">
        <value>com.mysql.jdbc.Driver</value>
    </property>
    <property name="url">
        <value>url</value>
    </property>
    <property name="username">
        <value>root</value>
    </property>
    <property name="password">
        <value>root</value>
    </property>
    <property name="maxActive" value="100"/>
    <property name="maxWait" value="10000"/>
    <property name="maxIdle" value="10"/>
</bean>
<bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" id="sessionFactory">
    <property name="dataSource">
        <ref bean="dataSource"/>
    </property>
    <property name="annotatedClasses">
        <list>
            <value>com.taher.test.model.StudentMaster</value>
            <value>com.taher.test.model.StudentDetail</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="current_session_context_class">thread</prop>
            <!--<prop key="hibernate.hbm2ddl.auto">update</prop>-->
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
            <prop key="hibernate.connection.autocommit">false</prop>
            <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</prop>
            <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop>
            <prop key="hibernate.max_fetch_depth">5</prop>
            <prop key="hibernate.default_batch_fetch_size">16</prop>
            <prop key="hibernate.jdbc.batch_size">25</prop>
            <prop key="hibernate.jdbc.fetch_size">8</prop>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.connection.release_mode">after_statement</prop>
        </props>
    </property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory" />

<bean  class="org.springframework.orm.hibernate3.HibernateTemplate" id="hibernateTemplate">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>

<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<!--DAO BEANS-->
<bean name="HibernateQueryDao" class="com.taher.test.dao.HibernateQueryImpl">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean name="StudentMasterDao" class="com.taher.test.dao.StudentMasterImpl">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean name="StudentDetailDao" class="com.taher.test.dao.StudentDetailImpl">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>

<!--Service BEANS-->

<bean name="wrapedStudentService" class="com.taher.test.service.StudentService" autowire="no">
    <property name="studentMasterDao" ref="StudentMasterDao"/>
    <property name="studentDetailDao" ref="StudentDetailDao"/>
</bean>
<bean id="StudentService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
    <property name="transactionManager">
        <ref bean="transactionManager"/>
    </property>
    <property name="target">
        <ref bean="wrapedStudentService"/>
    </property>
    <property name="transactionAttributes">
        <props>
            <prop key="insertStudentDetail">PROPAGATION_REQUIRED,-Exception</prop>
            <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
        </props>
    </property>
</bean>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:35:15+00:00Added an answer on June 2, 2026 at 6:35 pm

    Yeah got the solution :

    I had removed bean ‘TransactionProxyFactoryBean’ and added <tx:annotation-driven transaction-manager="transactionManager"/> and @Service to my Class and @Transactional to my method…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table say MyTable (myId,myStringCol1,myStringCol2,myStringCol3) When Using QUERY1 hibernateTemplate.find(SELECT new(myId,myStringCol1) from MyTable)
We are using hibernateTemplate for our dao's within my current project. I have a
My goal is to achieve delete all recommendations and then insert new. (any online
I have a jUnit4 test case class ( extends TestCase). I am testing some
I'm using Spring.net with NHiberante (HibernateTemplate) to implement my DAO's. I also have some
I have an issue trying to delete using hibernate. When I try to delete
Using Android 2.1+. I have a service that gets killed from time to time
I am using Spring HibernateTemplate, OpenSessionInViewFilter(actually I extended this class and created my own
Using the Redis info command, I am able to get all the stats of
I am importing stock quotes data using HibernateTemplate + SpringFramework Format of the data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.