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 706417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:09:50+00:00 2026-05-14T04:09:50+00:00

Just wanted your expert opinions on declarative transaction management for Spring. Here is my

  • 0

Just wanted your expert opinions on declarative transaction management for Spring. Here is my setup:

  1. DAO layer is plain old JDBC using Spring JdbcTemplate (No Hibernate etc)
  2. Service layer is POJO with declarative transactions as follows –
    save*, readonly = false, rollback for Throwable

Things work fine with above setup. However when I say get*, readonly = true, I see errors in my log file saying Database connection cannot be marked as readonly. This happens for all get* methods in service layer.

Now my questions are:

A. Do I have to set get* as readonly? All my get* methods are pure read DB operations. I do not wish to run them in any transaction context. How serious is the above error?

B. When I remove the get* configuration, I do not see the errors. Morever, all my simple get* operations are performed without transactions. Is this the way to go?

C. Why would anyone want to have transactional methods where readonly = true? Is there any practical significance of this configuration?

Thank you! As always, your responses are much appreciated!

  • 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-05-14T04:09:50+00:00Added an answer on May 14, 2026 at 4:09 am

    This post tells that the behaviour or the readOnly flag is persistence-mechanism-dependent.

    C. Yes, when using hibernate, it gives performance benefits by setting the flush mode to FLUSH_NEVER (as described in the linked post)

    B. Yes, JDBC calls do not require a transaction (hibernate requires one), so removing the @Transactional configuration trims all transaction management.

    A. I’d assume spring is calling connection.setReadOnly(true) but your JDBC driver doesn’t support this

    The bottom-line is : don’t use readonly transactions with plain JDBC.

    And another thing – transactions are supposed to span multiple queries. Don’t make your transactions too fine-grained. Make them a unit of work.

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

Sidebar

Related Questions

Just wanted your help on a CSS Positioning issue. Here is the link to
I have seen the GUID Collisons discussions but just wanted your thoughts on whether
I just wanted to hear your Opinion about a WCF Client implementation. I have
I just wanted to know your experience with using resharper. We have a very
I just wanted to see if I could have your thoughts on the design
I just wanted to share this Query class and get your thoughts on it.
I just wanted to ask if you can retrieve cookies in your asp.net application
Just wanted opinions on a design question. If you have a C++ class than
just wanted to ask where I define initial class properties? From other languages I
Just wanted to know how i would replace sitename.com with sitename2.com whenever a user

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.