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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:05:54+00:00 2026-05-23T04:05:54+00:00

In my application I have hidden the underlying storage objects behind interfaces, allowing me

  • 0

In my application I have hidden the underlying storage objects behind interfaces, allowing me to switch storage at will.

The issue is that when testing hibernate it seems that Hibernate is very Transaction oriented. Everything that I could find on the subject (mainly their official docs) says that autocommit is bad and should rarely be used. However my entire application isn’t written around Hibernate, its written around the interfaces. This means that getting data from the database happens in one method (eg getObjects() in the factory), not a Transaction.

Since I’ve abstracted away the storage implementation, is autocommit the right solution? Or is there an alternative?

  • 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-23T04:05:54+00:00Added an answer on May 23, 2026 at 4:05 am

    The use of auto-commit, does not mean that transactions are no longer used to access data. It simply means that each statement now executes in it’s own transaction. The exact instances when the transaction starts and terminates in defined in the JDBC specification. For the sake of brevity, this usually depends on the nature of the statement executed.

    I’m not sure of how your design is implemented, but non-transactional systems typically suffer from three problems. The use of auto-commit may reintroduce one or more of these problems.

    Dirty reads

    Consider a thread A in your application that would read an entity and update it, but not commit the new value. Consider another thread B that reads the same entity and sees the updated value. If thread A were to roll back it’s changes, or fail in committing the updated value, then B is essentially using a dirty value, for it performed a dirty read.

    On it’s own auto-commit does not result in dirty reads. However, if you have a sequence of database read-writes that were originally performed in a single transaction, making the sequence commit after every read/write operation, will result in dirty reads in a different transaction, for your current transaction might simply roll back the change.

    Non-repeatable reads

    In the context of a transaction, reading the same entity (record) twice in the context of a transaction, and seeing a different value on the second read is considered a non-repeatable read. This occurs when a different transaction has committed it’s change and an ongoing transaction reads the new value.

    Using auto-commit (or rather performing the read operations in two different transactions) will most likely result in non-repeatable reads, since both the read operations in the same thread will be execute in different transactional contexts, resulting in the second read seeing the committed value (from the transaction in a different thread).

    Phantom reads

    Very similar to non-repeatable reads, but not quite. In this case, the thread of execution performing the second read, will see additional data (and not updated data) in the form of new records.

    Likewise, using auto-commit will most likely result in phantom reads in your application for the same reasons.

    These issues will also depend on the database transaction isolation levels employed, but eventually when one uses an ORM framework, marking the start and end of transactions would be left to an application developer. While individual read-write operations may be isolated from each other by the database, it is upto the developer to ensure that work occurs in a transactional context. Using auto-commit changes the transaction context for every operation.

    TLDR

    Using auto-commit when performing transactional activities would mean that it is impossible to perform a rollback to a safe state, in the event of a failure during a “business transaction context”. As an aside, it is for this reason that auto-commits should be disabled when performing batch updates in JDBC. Using auto-commit will force a commit to occur for every update in the batch, when the real need is to commit at the end of the batch.

    I would recommend reading the book Java Transaction Design Strategies (available as a free ebook) to gain further insight into using transactions.

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

Sidebar

Related Questions

In my web application I have created a form that will allow users to
I have an application that needs to retrieve a value out of a hidden
I have an application that will be available across multiple versions of OS X.
We have hidden the status bar in our application. But when there is an
I would like to show some hidden text in a Flex application and have
I have application that makes different queries with different results so the caching in
I have a WPF application that calls an API to operate a device (a
In my Map application I have segment controller on main screen and using that
I have an application that on a subsequent start detects if there's a process
I have an application that runs in fullscreen mode and has been working fine.

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.