What is the best way to Update only 1 field of a big Business Object inside a transaction?

爱⌒轻易说出口 提交于 2019-12-01 01:50:26

I guess you mean exposing those 4 fields, instead of inheriting them since you cannot really inherit fields, only a class.

You could make a smaller, simpler 'update object', but I would only do so if this smaller object also exists logically in your model. Ideally, you really don't want to create special objects for updating only parts of your business objects. Instead, it's the task of your persistence layer to be smart enough to know which fields have changed and act accordingly (ie only update those fields).

So in summary:

  • Make an update object only if its also a logical part of your Domain Model
  • Trust in your persistence layer to see what has changed.

Create DTO with those 4 fields. UI will send this DTO to business layer which will use new values to modify business object. Than you persist that modified business object.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!