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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:40:23+00:00 2026-05-25T00:40:23+00:00

We are developing online schedule application. One schedule can be edited simultaneously by several

  • 0

We are developing online schedule application. One schedule can be edited simultaneously by several users. There is one very important business constraint. There must be only three events in one day.

Technically speaking and simplifying, there is a table in database with columns: | id | event | date |. Application runs in transaction “select… count… where…” and if result is less than 3, it inserts new event.

Wich approaches can be used to guarantee that two threads will not create four events in one day? This is a classical check-and-write problem. And we wonder how it can be solved on database level?

Using transactions doesn`t guarantee that in the second transaction another thread will not do the same: checks that number of events is less than 3 and makes insert. Locking the whole table is not acceptable because it will reduce response time, concurrency, etc.

Application is developed in Java using Spring, Hibernate, MySQL.

Thanks in advance for any pieces of advice.

  • 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-25T00:40:24+00:00Added an answer on May 25, 2026 at 12:40 am

    For blocking process you should use Select … FOR UPDATE statement. But this one works only in innodb.

    Example:

    //java logic
    try {
        //mysql logic
        start transaction;
        select * from where 'some condition' FOR UPDATE
        INSERT INTO TABLE ....    
        commit;
    //java logic
    catch (Exception e) {
        rollback;
    }
    

    See more info about specific row locking http://dev.mysql.com/doc/refman/5.1/en/innodb-locking-reads.html

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

Sidebar

Related Questions

As a follow up to this question: Developing a online exam application, how do
Developing a .NET WinForms application: how can I check if the window is in
My company is developing an online HR and Payroll application where securing access is
I'm developing an online baseball/softball scorebook application. I want to visually change the CSS
I am developing an online strategy game using .Net v2. Although the game is
I am developing an online exam using JSP/Servlets which is nearing completion. I'm planning
I am developing an online examination using servlets/jsp.I need to add a count down
Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
When developing a desktop application in .NET, is it possible to not require the
I'm thinking about developing online multiplayer social game. The shared state of the world

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.