开发者

JPA update a table

I am trying to update a table using JPA if I find that record using the primary key.During which I have a restriction should not update the record with null values开发者_如何转开发.If I have a table

Employee with columns emp_id,emp_name emp_name has a value and the new record does not have the value for emp_name in that case the old name should be retained.Is it possible?


When you find() the original employee it will have the old values. Where does your new record come from? Say it is some detached employee, then simply only overwrite the attributes that are not null into the managed employee.

JPA merge() will always merge everything. In EclipseLink you can set a FetchGroup on an entity being merged, and only the fetched attributes will be merged.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜