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

前端 未结 2 631
感动是毒
感动是毒 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.

提交回复
热议问题