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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:11:04+00:00 2026-05-22T12:11:04+00:00

I faced a problem. I have an App with Hibernate that loads data from

  • 0

I faced a problem. I have an App with Hibernate that loads data from XML files into tables in concurrent mode. Some part of data could be same and could be inserted from differnet threads. Each thread works in its own long-play transaction. There’s an issue when two or more treads try to commit transaction. For example two threads inserted records into table City that has constraint on NAME field. It means that ConstraintViolationException occurs on flush() or commit(). I want to automatically handle this collisions and want new problem objects to be replaced with older already inserted objects. Is this possible? I look at saveOrUpdate() and optimistic version control in Hibernate.

  • 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-22T12:11:04+00:00Added an answer on May 22, 2026 at 12:11 pm

    I assume that you use one of MVCC-based DBMS.

    If transaction isolation level is not higher than READ COMMITTED, you can reduce probability of conflict by issuing a query to check for existence of Cities with the same name before inserting the new one.

    Note that saveOrUpdate() can’t help here, since name is not a primary key. Also note that you cannot prevent conflict at all (at least without using some DBMS-specific features), since basically it’s an example of write skew anomaly, which can’t be prevented in MVCC-based DBMS.

    Also, if atomicity of importing XML file is not critical, you can break long transaction into several shorter ones, and simple retry them in a case of constraint violation.

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

Sidebar

Related Questions

Hello I faced the same problem I have 1 broadcast receiver from that I
We've faced strange problem. We have log on service, that authenticates user, adds auth
I have a problem that I have not faced before: It seems that the
I have faced this problem quite often during the last couple of months, during
We have recently been faced with the problem of porting our C++ framework to
I have designed a custom section handler before but I'm faced with a problem
Today I faced a strange problem in C#. I have an ASP.NET page where
I am currently faced with a difficult sorting problem. I have a collection of
I faced with problem that geomap by google fails with JQuery together in Internet
I'm faced with the problem that my applications global variable destructors are not called.

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.