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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:28:34+00:00 2026-06-13T21:28:34+00:00

Background: I am working on a MYSql database where multiple instances reads from the

  • 0

Background: I am working on a MYSql database where multiple instances reads from the same Account Table . I want to implement row level exclusive lock using Hibernate Query Language to avoid dirty read.

My code is as below.

List<AccountTableBean> currentRequestslist = sessionFactory.getCurrentSession()
                .createQuery("from Account where status = :finalStatus")
                .setLockMode("MappCurrentRequests", LockMode.PESSIMISTIC_READ)
                .setParameter("finalStatus","Active").list();   

Currently, I have used Pessimistic_read on the entire table. Is there a way i can apply to lock on individual rows? Any example will be very helpful.

Thank you,
Gendaful

  • 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-13T21:28:35+00:00Added an answer on June 13, 2026 at 9:28 pm

    The locking type is implied by the database itself.

    If you are using MyISAM storage engine, there is nothing you can do to force row level locking, no matter how hard you try – either in raw SQL or in JDBC. MyISAM simply does not support row level locks.

    Simply switch to using InnoDB and you won’t even have to call setLockMode in order to get the necessary lock type.

    From the manual:

    MySQL uses row-level locking for InnoDB tables to support simultaneous
    write access by multiple sessions, making them suitable for
    multi-user, highly concurrent, and OLTP applications. MySQL uses
    table-level locking for MyISAM, MEMORY, and MERGE tables, allowing
    only one session to update those tables at a time, making them more
    suitable for read-only, read-mostly, or single-user applications.

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

Sidebar

Related Questions

BACKGROUND I'm working with a MySQL InnoDB database with 60+ tables and I'm creating
I want to access a MySQL database directly from JavaScript code in an HTML
Here's some background info. I have three MySQL tables (all InnoDB). The first table
I have background service which access my SQL Server database. My background service working
I need help with displaying images from a MySQL database. What I have is
I need help with displaying images from a MySQL database. What I have is
Background: I had a working database called WBPM which I renamed using the right-click
Background: working a user q&a site where users logged,etc. What user/visitor data should be
Background I am working with a monad built of a stack of transformers one
BACKGROUND: I am working with large geometries that will be meshed or broken down

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.