java - How should the DAO design strategy be for update operation ? -
i myself surprised question never occurred me before time bothered since creating own application.
i have taskdetail class has 30 fields. while updating there small part of taskdetail may updated "enddate" of task. can use 2 strategies update field.
- approach 1 : update entire object 30 fields , let rest fields overwritten in database same value expect changed field updated new value. or
- approach 2 : update field has been changed. in case treat employee dto , populate "enddate" field new value since field needs changed.
both approaches seem have pros , cons
approach 1 : (pros) - cleaner approach. (cons) - unnecessarily over-writing 29 additional field sake of 1 field.
approach 2 : (pros) - updating fields modified (cons) - makes dao dirty looking because need 30 null checks identify of field have updated.
this problem making me little uncomfortable.
which of approach accepted 1 or there third approach? not in favor of using hibernate although prefer spring jdbc template.
just going gist of information - approach 1 performance overhead updating 29 fields every time each update. can have more update operations based on fields update more based on usecase. more worried performance, maintainability , atomicity when compared how dao looks long not complexly written.
Comments
Post a Comment