I use 2.5 and do everything through annotations.
I have a simple form that allows the user to edit an object. The controller behind it creates an object and adds it to the GET model and processes the changes in POST (submit). It works great, but I donโt understand why. The object is never explicitly added to the session, and the id object is not passed to the submit method. How does the controller send method know the "id" value of an object?
The reason for this question is because I have a different form / controller that is almost identical to the above, but does not work unless I add an object to @SessionAttributes. The difference is that the object this particular controller is working with has a link to another object that is lazily loaded (I use Hibernate behind the scenes). When I submit a form without putting the parent in SessionAttributes, I get a DataIntegrityViolationException because I never load the specified object.
When I add the parent to @SessionAttributes, the problem magically disappears. I speak magically, because although I put the parent in the session in GET, I still have never loaded an explicit reference object, so it should be empty (or an empty proxy server or something else).
What is happening in the world? I need help!
Boden source
share