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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:52:06+00:00 2026-05-24T05:52:06+00:00

I am developing a Spring/Hibernate application and I am seeing some unexpected behaviour whilst

  • 0

I am developing a Spring/Hibernate application and I am seeing some unexpected behaviour whilst trying ot make updates to existing objects.

Currently, I have a service class method that simply updates an object as follows:

@Transactional
public void updateToDoCompletion(long id, boolean completed){
    ToDo todo = getEntityManager().find(ToDo.class, id);
    if (todo!=null){
        todo.setCompleted(completed);
    }
}

My understanding is that a transaction is started around the method, the ToDo object is loaded (within the transaction) and then any changes that I make to that object will be persisted once the transaction has ended (in this case, the method is being called from outside a transaction, in my controller class, so I expect the transaction just to last for this method).

However, having run through the above, the changes to the object are never being persisted to the database.

Interestingly, this update at the end of the transaction is working elsewhere in almost identical setups (in terms of expected transactional boundaries etc), so I was experimenting with the code and updated the method as follows:

@Transactional
public void updateToDoCompletion(long id, boolean completed){
    ToDo todo = getEntityManager().find(ToDo.class, id);
    if (todo!=null){
        todo.setCompleted(completed);
    }

    Team t = conService.loadTeam(50l);
    t.setDescription("test description!");
}

This time, after making changes to the original object, I have loaded a different object, and made a change to that – I did this as the only difference I could see to other methods that were working as expected were they made calls to Transactional methods in other classes (so the added code, conService.loadTeam(50l) is a transactional method in another service class). Now, the original changes to the ToDo object are being persisted as I hoped, but the changes to the Team object are not.

So my questions are:

  1. Have I wildly misunderstood some concept of the hibernate transactions?
  2. Why, on adding the call to the other transactional conService class does my original object now start getting persisted
  3. Why isnt the Team object changes getting persisted? (obv I dont want to make this code in here, but interested to understand exactly what is going on)

Thanks

  • 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-24T05:52:07+00:00Added an answer on May 24, 2026 at 5:52 am

    Ok, it seems as though the addition of the call to the other service class was a red herring – it seemed that a lot of the persistence was being a bit flaky, and if I clean the project and restart the server then the original code works correctly.

    Has anyone else found this? I’m using Elcipse Gallileo and Tomcat.

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

Sidebar

Related Questions

I'm developing an application in Spring 3.0.5 and Hibernate 3.6.2, and currently i'm working
Hey I am developing an desktop application using Spring and Hibernate, and I have
We are developing a web application using Spring framework and Hibernate ORM. As far
I'm developing a web application on Apache Tomcat 6 with Hibernate and Spring, I'm
I am using Spring Web MVC and Hibernate for developing my application. My login.jsp
I am using Spring, Hibernate for developing my application. And as DB side, I
I am developing an application using SPRING 3.0.4, JPA 2, Hibernate 3.5.5. I an
I'm developing a web application based on JPA + Hibernate, Spring and Wicket. I
I'm developing a web application using Wicket+Spring+JPA+Hibernate. This is my first project with this
I'm developing an example web-application, using JPA 2.0 entities, Hibernate 3.6.2 and Spring 3.

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.