update fields or table using DAO/DTO
843859Jan 22 2008 — edited Nov 20 2014Hello:
I am designing an application using DAO/DTO. I have a Person class and an Address class. Person object includes an address object. I have a method to update a person if any of his/her data is changed. This means that potentially I need to update both Person table and Address table.
The problem is that under the situation that I didn't change everything of the person object. Say, I only changed "date of birth". In this case, did I still update both tables? Or if I changed some fields in Address table, say street name and zip code. Do I need to update the person table as well? To update all fields seems clean but redundant. What do you suggest that I should do? Do you do a check to see which field(s) is (are) changed? Then you will end up with many update statements? Please advise.
Thank you
-Rick