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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:05:54+00:00 2026-06-07T06:05:54+00:00

Exception org.hibernate.exception.LockAcquisitionException: could not insert appears sometimes in the following code: Question questionClone; try

  • 0

Exception “org.hibernate.exception.LockAcquisitionException: could not insert” appears sometimes in the following code:

 Question questionClone;
 try {
    questionClone = (Question) question.clone();
 } catch (CloneNotSupportedException e) {
    throw WrappedException.wrap(e);
 }
 questionClone.setCategory(question.getCategory());
 questionClone.setOriginal(false);
 logger.trace("Saving questionClone " + questionClone + " start");
 hibernateSession.save(questionClone);
 logger.trace("Saving questionClone " + questionClone + " end");

when questionClone is saved. Here is the clone method for Question:

public Object clone() throws CloneNotSupportedException {
    Question questionClone = (Question) super.clone();

    questionClone.category = null;

    List<Alternative> alternativesClone = new ArrayList<Alternative>(getInternalAlternatives().size());
    int index = 0;
    for (Iterator<Alternative> iterator = getInternalAlternatives().iterator(); iterator.hasNext();) {
        Alternative alternative = iterator.next();
        Alternative alternativeClone = (Alternative) alternative.clone();
        alternativeClone.setQuestion(questionClone);
        alternativeClone.setIndex(index);
        alternativesClone.add(alternativeClone);
        ++index;
    }
    questionClone.setInternalAlternatives(alternativesClone);

    return questionClone;
}

And clone method for Alternative:

public Object clone() throws CloneNotSupportedException {
    Alternative alternativeClone = (Alternative) super.clone();

    alternativeClone.index = 0;
    alternativeClone.question = null;

    return alternativeClone;
}

Hibernate mapping of question contains this:

<list name="internalAlternatives" inverse="true" cascade="all-delete-orphan">
   <cache usage="read-write"/>
   <key column="QUESTION_ID"/>
   <list-index column="INDEX"/>
   <one-to-many class="Alternative"/>
</list>

Exception states that it cannot insert an Alternative and caused by: com.ibm.db2.jcc.am.SqlTransactionRollbackException: DB2 SQL Error: SQLCODE=-911, SQLSTATE=40001, SQLERRMC=2, DRIVER=4.14.88. As I found out it was a deadlock. Can anyone help with this?

  • 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-07T06:05:54+00:00Added an answer on June 7, 2026 at 6:05 am
    alternativeClone.setQuestion(questionClone); 
    

    and

    questionClone.setInternalAlternatives(alternativesClone);
    

    Seems to be the dealock occurs becuase of these lines. You are adding list on internalAlternatives inside your question, and then also setting question inside alternative.

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

Sidebar

Related Questions

Whenever I'm disconnected from the internet, I get the following exception: org.hibernate.HibernateException: Could not
I have a grails project that is throwing the following exception: org.springframework.dao.DataIntegrityViolationException: could not
I am getting the following exception while adding data into database: org.hibernate.HibernateException: The database
I'm try to insert or update db record with following code: Category category =
I get the following exception: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags the bean I
I've been trying to fix this error: {exception:Persistent class \Class org.myapp.model.Account does not seem
I try to executer bulk delete using Hibernate HQL query, following reference manunal but
I am getting an exception: org.hibernate.MappingException: No Dialect mapping for JDBC type: -9 I
I have two classes mapped OneToMany, ManyToOne, and i get exception: org.hibernate.AnnotationException: mappedBy reference
I have this error when trying to generate the meta model with JOOQ: org.jooq.exception.DataAccessException:

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.