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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:56:05+00:00 2026-05-29T13:56:05+00:00

In order to debug an issue with our usage of Hibernate, I would like

  • 0

In order to debug an issue with our usage of Hibernate, I would like to disable Hibernate’s batch insert/update mechanism to use non-batched statements instead.

I know that I can set hibernate.jdbc.batch_size=1, but that still goes through the normal batching code with a batch size of 1.

Is there any way to completely turn off batch processing?

  • 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-29T13:56:07+00:00Added an answer on May 29, 2026 at 1:56 pm

    As far as I understand you want to avoid calling the PreparedStatement#addBatch(sql) method by Hibernate (and instead use dedicated statement instance for every operation). Unfortunately there is no easy way to do that. But… I have checked the Hibernate source code and it seems that Hibernate checks multiple conditions before running the update/insert operation. It decides wheter to use batch or not. Have a look at the method AbstractEntityPersister#update. There should be a line like this:

    final boolean useBatch = j == 0 && expectation.canBeBatched() && isBatchable(); //note: updates to joined tables can't be batched...
    

    One thing which you can do is to replace isBatchable() method by your own implementation which will always return false. By default it looks like this:

    public boolean isBatchable() {
            return optimisticLockMode()==Versioning.OPTIMISTIC_LOCK_NONE ||
                ( !isVersioned() && optimisticLockMode()==Versioning.OPTIMISTIC_LOCK_VERSION ) ||
                getFactory().getSettings().isJdbcBatchVersionedData();
        } 
    

    Therefore you could choose one of the following approaches:

    • create your own implementation of EntityPersister
    • replace the Hibernate source code
    • tweak the configuration by setting the property hibernate.jdbc.batch_versioned_data = false and by setting locking mode for every entity which you have to OPTIMISTIC_LOCK_ALL.

    As I said before not simple but possible.

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

Sidebar

Related Questions

In order to debug I would like to dump certain variables on to my
In order to develop and debug mobile and tablet applications, I'd like to be
Issue We are using config transforms inside our solution. For example: Debug, Test, Staging,
In order to debug an issue in my code, I have declared the following
in order to recover data from server I use XMLHttpRequest and my code is
in order to avoid copy/paste, i can use a unique view for different actions,
Sometimes I have come across this issue that whenever I change the order of
I am currently trying to learn how to use premake 4 in order to
I am running into a wierd issue with the execution (or non-execution) of certain
I am having a weird issue with VS 2008 when I go to debug

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.