-
Sep 24th, 2010, 03:39 PM
#1
How to update entity partially
Hi,
I have an entity Userinfo having many fields. Some are with NotNull and some allows null value.
Method Signature:
@RequestMapping(value = "/userinfo/{id}/update", method = RequestMethod.POST)
public String updateintercept(@Valid Userinfo userinfo, BindingResult result, ModelMap modelMap,HttpServletRequest request) {
...........
}
Entity: Userinfo
Fields:
userid(NotNull ),
password(NotNull ),
emailId(NotNull ),
phone,
enable(NotNull ),
creattionDate(NotNull ),
updationDate(NotNull )
Now I want to update selected fields like email, phone, enable.
I don't want to populate those fields into the form which are not getting updated.
result.hasErrors() method returning true.
Please suggest me the required changes in my code.
Thanks & regards,
Punit Kumar Dwivedi
-
Sep 24th, 2010, 09:47 PM
#2
I assume you dont want to update the creation date in this case,
You can use JPA @Column(updatable = false)
I have a similar setup which uses a BaseEntity with userWhoCreatedd/timeCreated , userWhomodified/Timemodified updated with Aspects,
-
Oct 9th, 2010, 08:35 AM
#3
I have similar problem, but JPA with 'updatable' is not what I want. I have form that need to update only one field i.e. 'phone' (I don't want to populate in the page all fields like 'password', 'enable', ...).
-
Oct 9th, 2010, 01:34 PM
#4
Hi entaroadun7,
You should user following annotation for password, enable.
@Column(updatable=false)
-
Oct 10th, 2010, 03:44 AM
#5
Hi,
I can't use 'updatable=false' because I have other forms where I allow to change password and enable.
-
Oct 10th, 2010, 06:05 AM
#6
Well in that case you will need to have to write a custom form, controller and validator.
You can probably reuse the form and controller with some if statements but the controller uses imlicit validator for your entity in ROO.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules