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

  • Home
  • SEARCH
  • 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 8019671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:27:36+00:00 2026-06-04T21:27:36+00:00

As it is mentioned in blogs/books (e.g. Java Transactions Design Strategies by Mark Richards),

  • 0

As it is mentioned in blogs/books (e.g. Java Transactions Design Strategies by Mark Richards), read operations must have the Propagation.SUPPORTS attribute.

In a simple Spring 3.1 MVC project with Hibernate 4.1 the scenario is:

  • Declarative transaction management using @Transactional
  • sessionFactory of org.springframework.orm.hibernate4.LocalSessionFactoryBean
  • Transaction manager of org.springframework.orm.hibernate4.HibernateTransactionManager
  • Service class with @Transactional(propagation=Propagation.REQUIRED)
  • Function of that Service class that only retrieves a resultset (performs read operation) with @Transactional(propagation=Propagation.SUPPORTS)
  • Function of read operation retieves the resultset using sessionFactory.getCurrentSession().get()

Of course, when a Controller executes the function of read operation, the exception “No Session found for current thread” is raised because a transaction is not started and a session is not obtained.

Based on the above configuration (while it is best e.g. non-invasive, less code etc) the Propagation.SUPPORTS attribute cannot be used unless a transaction is started before with Propagation.REQUIRED or Propagation.REQUIRES_NEW.

How do we use use Propagation.SUPPORTS for read operations without having to start a transaction e.g. with Propagation.REQUIRED before but still taking advantage the benefits of declarative transaction management?

Thank you in advance.

Coder, here is the configuration:

<tx:annotation-driven transaction-manager="txManager"/>

<context:component-scan base-package="com.myapps.service.impl" />

<bean id="txManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${db.driverClassName}" />
    <property name="url" value="${db.url}" />
    <property name="username" value="${db.username}" />
    <property name="password" value="${db.password}" />
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="mappingResources">
        <list>
            <value>.....</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${db.dialect}</prop>
            <prop key="hibernate.format_sql">true</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-04T21:27:37+00:00Added an answer on June 4, 2026 at 9:27 pm

    I disagree with using SUPPORTS for read operations. Use REQUIRED.

    • A transaction is needed anyway to perform every database operation
    • Doing several small transactions to read several things at once won’t benefit from the first-level cache
    • There won’t be any isolation between all the subsequent reads, meaning that something not visible to the first read might become visible for the second one
    • you’ll get lazy loading exceptions when traversing associations
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does phonegap supports offline storage cache manifest mentioned in this article http://blogs.missouristate.edu/web/2010/05/12/google-maps-api-v3-developing-for-mobile-devices/ ? I
Someone mentioned that immediate or self-executing functions have to store the whole stack. Is
Recently Zed Shaw (a programmer who blogs) mentioned that ODBC references should be removed
I have configured manifest.mf file to add custome attributes as mentioned here: http://twit88.com/blog/2008/02/20/maven-adding-custom-attributes-and-build-timestamp-to-manifest/ .
When I read books about WPF, I saw the authors mention XPS like it
I've seen it mentioned in many blogs around the net, but I believe it
I am using John resig's implementation class mentioned here: http://ejohn.org/blog/simple-javascript-inheritance/ Now I have a
I've seen this HTML notation on blogs but they don't mention how to use
As mentioned here , you can use the star for unpacking an unknown number
As mentioned in the title, I want to find the pairs of elements whose

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.