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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:45:15+00:00 2026-06-13T11:45:15+00:00

We are using Hibernate 3.6.1.FINAL against Oracle 11g . We are experiencing blocking locks

  • 0

We are using Hibernate 3.6.1.FINAL against Oracle 11g.

We are experiencing blocking locks in our database that I believe is caused by an unexpected side-effect of Hibernate.

This is a critical issue we need to resolve, as the database blocking locks quickly snowball and transactions begin timing out, causing a production outage.

I am trying to figure out if there is a certain scenario in which Hibernate can do a behind-the-scenes delete and re-insert of a collection of children, or some way that it could cause blocking locks on a delete/insert.

I’m looking for ideas/suggestions/insight about possible causes, not necessarily an exact answer.

I’ve isolated the entities involved and their mappings. Unfortunately due to the fact that we have a huge legacy system with tons of code, I had to come up with a simplified example:

Parent.hbm.xml

// Parent has a unique ID generated with a Sequence,
// an index column called ORD, and a Version column called UPDATE_COUNTER.
<!-- bi-directional one-to-many association to Child -->
<bag
    name="children"
    lazy="false"
    inverse="true"
    cascade="all-delete-orphan"
    order-by="ord asc">
    <key column="PARENT_ID" />
    <one-to-many class="Child" />
</bag>

Child.hbm.xml

// Child has a unique ID generated with a Sequence, 
// and a Version column called UPDATE_COUNTER.
<!-- bi-directional many-to-one association to Parent -->
<many-to-one
    name="parent"
    class="Parent"
    not-null="true"
>
    <column name="PARENT_ID" />
</many-to-one>

Our DBAs have reported that they see the following:

The Blocked SQL:

insert into CHILD (UPDATE_COUNTER, ORD, PARENT_ID, ID) values (:1 , :2 , :3 , :4)

The Blocking SQL:

delete from CHILD where ID=:1  and UPDATE_COUNTER=:2

Here’s what I’ve tried thus far:

  1. Did a full audit of our codebase, established that there is nowhere where we delete and insert a row with the same primary key. All of our INSERT for Child is done with ID set to null, in which case the Sequence will generate the Unique ID.

  2. Turned on show_sql. Also, DBAs set up a trigger on Child to capture all DML activity so we could get the bind variables in development.

    I found the following articles saying that Hibernate could do delete all then re-insert for bags and lists:

    Why Hibernate does “Delete all then re-insert”

    Hibernate – set, map, bag & list differences

    However, I determined that this is not occurring. I wrote test code that removes one of the Child objects in the middle (ORD=5 with a collection of 10 children that had ORD=0 through ORD=9) and then saved Parent.

    I saw in the DML activity table that a delete was issued for the removed Child and UPDATE was done for the remaining 9 children that set their ORD to the correct value.

As I mentioned, I’m not looking for an exact answer. I would just be tremendously grateful if anyone who has a lot of experience with Hibernate could lend any insight or suggestions as to additional paths or avenues I could run down.

Thank you very much in advance.

  • 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-13T11:45:16+00:00Added an answer on June 13, 2026 at 11:45 am

    You may want to consider adopting Pessimistic Locking. Once done… Hibernate will always use the locking mechanism of the database; it never lock objects in memory.

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

Sidebar

Related Questions

When using hibernate to retrieve data from Oracle 11g DB using either org.hibernate.dialect.Oracle10gDialect or
I'm using Hibernate v4.1.4.final.jar using Java 1.7 to connect to Oracle 10g server. And
I'm using Hibernate 4.0.1.Final with a MySQL 5.5 database. I'm writing a Java console
I'm using Hibernate 4.0.1.Final. I'm having trouble binding a session when testing my service.
I'm using Hibernate 4.0.1.Final to write a standalone Java app. When testing my data
I'm using Hibernate 4.0.1.Final. I'm trying to run a JUnit test on my DAO
I'm using Hibernate 4.0.1.Final. I have a table with a unique constraint column …
I'm using Hibernate 4.0.1.Final and MySQL 5.1. My domain object contains a java.util.Calendar object
Using Hibernate EntityManager 3.5.3-Final together with Unitils 3.1 results in: unitilsAfterTestTearDown(com.unifiedpost.payments.model.TestAccount) Time elapsed: 0.02
I'm using Hibernate 3.5.2-FINAL with annotations to specify my persistence mappings. I'm struggling with

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.