May 30th, 2009, 07:43 PM
Model attribute contain partial hibernate object
I am using spring+spring MVC+hibernate for my product.
I have the following scenario
I have a persitant object "A" which have attributes x,y,z. I am using "A" as the model attribute while rendering my page for editing the persisted instance of "A".But I am going to allow the user to edit only y and z and hence displaying only those two in the page.So when the user submits the page , I get values only for y and z not for x ,and x become 0 (as x's type is integer). As I save the model object to the db using hibernate,my existing value of x in the db getting overwritten.This even leads to UnsavedPersistanceObject exception, if x is an object reference.This is all becase , I dont have a corresponding input field in my view(jsp) for attribute x. hidden input type can be a solution,but not feasible for me in my scenario, as the fields are hidden/shown dynamically, and there are lot of x's in the page.
Can anybody suggest me a solution .
Thanks in advance.