Announcement Announcement Module
No announcement yet.
updating object problem: hibernate + spring Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • updating object problem: hibernate + spring

    Short summary:

    update a parent and add a new chiild to it. saveorupdate the parent saves the child but loses the updates to the parent. Huh?

    Longer description:

    I've built a JSP/Spring/Hibernate app using the Spring web support.

    I have an "Issue" object that contains a Set of "Responses".

    When someone chooses to add a "Response" to an "Issue" they hit an "Add Response" link, an AddResponseController gets invoked which generates, as a form backing object, a new "Response" and sets the "Issue" on the response.

    In the form I can then edit the new Response and also make changes to a couple of fields from the Issue (which the form gets from the Response passed in).

    Then on submit the controller does a Save on the Issue and because I've setting the Hibernate mapping file to cascade saves and updates, so does the Response.

    Checking the database the Response does get added correctly but the updates I've made to the Issue are written to the database. Anyone have any idea why?[[/u]

  • #2

    Without seeing your code, I am unable to tell exactly why this is occuring. However, you should try enabling Hibernate debugging and see if the appropriate SQL queries are being executed and whether Hibernate is actually detecting the changes in the object.