Update counter in a table from Hibernate

Posted on 2012-08-22
Last Modified: 2012-09-10
we have a requirement to increment a counter in the database tables from a java program. There can be multiple java processes incrementing the counter. How can we make sure that the counter is incremented correctly, so that there are no dirty reads by the processes and increment on a stale value.

using Hibermate mapping to that table.

Note: this is not the ID column.
Question by:dhuma
    LVL 12

    Accepted Solution

    Bad idea incrementing DB counters from client side . This should be actually done on the DB side

    Author Comment

    this is the counter we use on how many messages were processed by the client programs.

    Author Comment

    is there a way to acheieve this from hibernate ?

    Author Closing Comment


    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    PGP Decryption code using Bouncy Castle jars 11 71
    zeroFront challenge 7 58
    bunnyEars challenge 6 46
    countAbc challenge 9 35
    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now