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

  • Home
  • SEARCH
  • 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 7188647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:07:50+00:00 2026-05-28T19:07:50+00:00

When I try to commit my session and another user also changed that same

  • 0

When I try to commit my session and another user also changed that same object, then Hibernate throws a StaleObjectStateException.

When I try to recover from that exception I call:

session.refresh(<staleObject>)

Then I once again call the commit that previously failed. But the staleObjectStateException occurs once again on the same object. Even if there are no changes made by another user, I also verified that the version number of the object is the same as the number in our DB.

Anyone know what might be wrong?
Does anyone have a better idea on how to gracefully handle the exception without closing and opening a new session?

note: we use a Single Session per View implementation for our desktop (RCP) application

  • 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-28T19:07:51+00:00Added an answer on May 28, 2026 at 7:07 pm

    As you have mentioned its a long running session, as per hibernate doc for refresh() method,

    Re-read the state of the given instance from the underlying database.
    It is inadvisable to use this to implement long-running sessions that
    span many business tasks. This method is, however, useful in certain
    special circumstances. For example
    where a database trigger alters the object state upon insert or update
    after executing direct SQL (eg. a mass update) in the same session
    after inserting a Blob or Clob

    I would suggest you to change the strategy of using the single session across the application life cycle, and use session but transaction meaning open session only when you need to interact with database and once done, close the sesion.

    I am not ware of any compulsions you have for using long running session, this is just a suggestion.

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

Sidebar

Related Questions

When I try to commit SVN reports about 10 old directories as missing. I've
I keep getting this error when I try to commit a group of executed
What would possibly cause a 'git push' to try and commit to two branches?
I need the ability to run an arbitrary command when I try and commit
I commit all my files into bitbucket. i try check in,revert file i deleted
I have an object where I maintain a relationship to another object: public class
I am using hibernate and whenever I try to add a record it drops
I am using Hibernate in NetBeans. I am using the hibernate util class that
I understand that you should always use transactions. I also see that NHibernate.ITransaction implement
I run following working code: Session session = null; try { SessionFactory sessionFactory =

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.