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

前端 未结 2 605
感动是毒
感动是毒 2021-01-07 13:06

I am in a situation where I have to perform a transaction master detail record (Drop prev details, insert new details, Update Master status)

  1. <
相关标签:
2条回答
  • 2021-01-07 13:36

    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.
    0 讨论(0)
  • 2021-01-07 14:01

    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.

    0 讨论(0)
提交回复
热议问题