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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:45:53+00:00 2026-06-06T20:45:53+00:00

I have a scenario where if a transaction starts for the database then no

  • 0

I have a scenario where if a transaction starts for the database then no reading and updation operations should be allowed until the started transaction got committed or rolledback.

For Example:
if I try to insert a row then there are some specific changes to be done to already existing rows in the database,if any other transaction or database query reads the data before the changes are complete,then we’ll end up having bad values in the database,so how to control the queries.

What I exactly want to do is when ever a transaction starts I want to put a lock to database,How to do this?

I’m using Hibernate transaction(declarative transaction) @Transactional(readOnly=false,propagation=Propagation.REQUIRES_NEW) can I add any other attributes to the transaction that suffices my requirement.

  • 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-06T20:45:54+00:00Added an answer on June 6, 2026 at 8:45 pm

    You should not have to do that. Transactions run in isolation from each other. In the default isolation level (READ_COMMITTED, most of the time), each transaction only sees what other transactions have already committed. So if you have one parallel transaction reading from the database while your transaction is running, this parallel transaction won’t see the changes of your main transaction until it has committed. Each transaction will see a coherent snapshot of the database.

    This is sufficient in most of the cases. If it’s not sufficient, you might want to use a higher isolation level (like REPEATABLE_READ or even SERIALIZABLE, if your database supports them), but completely locking the database is impossible, and not desirable.

    Read http://en.wikipedia.org/wiki/Isolation_%28database_systems%29 for more details about what each isolation level guarantees, and read your database documentation to see which levels it supports.

    Side note: @Transactional is a Spring annotation, not a Hibernate one.

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

Sidebar

Related Questions

I've got a scenario where I have a database with one table that gets
I have a scenario where I need to do the following in a transaction:
Here is the scenario: I have an object called a Transaction that needs to
My scenario is that I have some payment transaction data in MySQL and some
I have below scenario Got n as minimum number of rows required for the
I have the following strange scenario with spring's transaction management: I have method A
We're running into transaction issue with Grails. During performance test we have a scenario,
I have a scenario where I am looping through a resultset within a transaction
I have scenario to use the Temporary user defined type variable in transaction, but
Imagine the following scenario: I am using SQL Server 2005. I have a transaction

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.