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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:11:14+00:00 2026-06-06T18:11:14+00:00

I have an application I’d like to test-proof against possible problems related to Hibernate

  • 0

I have an application I’d like to test-proof against possible problems related to Hibernate and/or persistence.

What other problems? How do I reproduce them (literally)? And how do you recover from them?

To make it clear: I’m talking about multi-threaded cluster environment (the most complex one).

My one:

org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)

Reproduce:

  • Load the object.
  • UPDATE using HQL.
  • Try to update (save) the loaded object.

Handle: Not sure…

  • 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-06T18:11:16+00:00Added an answer on June 6, 2026 at 6:11 pm

    Lazy loading is one the big issues you’ll encounter, especially if you follow a standard DAO pattern. You’ll end up with lazy loaded collections, but upon coming out of your DAO layer, spring (or something else if you’re not using spring) might close the session.

    public class MyDaoImpl implements MyDao {
       @Override
       @Transactional
       public void save(MyObject object) { ... }
    }
    

    In this case, when the call to “save” completes, spring will close your session if you are not within another transaction. As a result, any calls to lazily loaded objects will throw a LazyInitializationException.

    The typical way to handle this is to bind a session to the current thread. In webapps, you can do this easily with the OpenSessionInViewFilter. For command line, you’ll probably need to write a utility method which creates a session, binds to the current thread, and then unbinds when you’re done. You can find examples of this all over the web.

    And on the subject of collections, if you use the “update” method (again something you’d typically do with a standard DAO pattern), you have to be careful not to replace collection instances, but rather you should manipulate the collection that’s already in place. Otherwise, hibernate will have a hard time figuring out what needs to be added/removed/updated.

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

Sidebar

Related Questions

I have application that displays webpage with url something like https://www.test.com/checkout/reserve/DHrhrzPEC6MepeMoZinxoQD4QvAaevgx7xYDZJtX8azf0_ii_Zv2b2rpiYgToXHP from this url
I have application that uses IPv4 addresses (it stores them as long), so it
I have application that produces files. I would like to connect those files with
I have application that look like below without spring (prior) UI-> service --> javabean
I have application that generates a lot of numbers and writes them to table
i have application that generate php/html/asp web sites and i like to be able
I have application where default Window's borders switched off Window tag definition looks like
I have application with two thread. One of them (T1) is main GUI form,
I have application which loads images like this: someImage = Image.FromFile(@picture.png); and another application
I have application that is only landscape with no other orentation supported. But when

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.