I am working on a Spring MVC based application. The process flow is as follows:
- Fetch the data from DB (table mapped to a POJO)
- Display a form backed by the POJO (from step 1). Not all the fields are displayed (like Primary Key etc).
- User can update some field value in the form and will then submit.
On receving the updated POJO using @ModelAttribute annotation in my Controller, I found that not all the fields are populated in the POJO received via @ModelAttribute. All the fields which were not mapped on the JSP (like primary key) are set to null or their default value in case of primitives. Due to this I am not able to update the same in the DB.
One solution that I found is I can use fields but that does not sound much efficient solution as I have a large number of attributes which are not displayed on the JSP page.