DAO and DTO
08 Jan 2017DTO is an abbreviation for Data “Transfer” Object.
<ul><li>It is used to transfer the data between classes and modules of your application, typically with data/values from database. DTO should only contain private fields for your data, getters, setters and constructors. It is not recommended to add any logic methods to such classes.</li></ul>
DAO is an abbreviation for Data “Access” Object.
<ul><li>It should have the logic for retrieving, saving and updating data in your database.</li></ul><div>
</div><div>Business Object is the class that uses DAO and DTO. Consider this is our servlet. It also has all logics (methods to do stuff etc).
</div><div>
</div>
<div class="separator" style="clear: both; text-align: center;"></div>
Here is an example how the DAO and DTO interfaces would look like:
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;">
</div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/9fVQ_mvzV48/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/9fVQ_mvzV48?feature=player_embedded" width="320"></iframe></div><div class="separator" style="clear: both; text-align: center;">
</div><div class="separator" style="clear: both; text-align: center;">
</div><div class="separator" style="clear: both; text-align: center;">
</div><div style="text-align: center;"><iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/1ui5yVMivTo/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/1ui5yVMivTo?feature=player_embedded" width="320"></iframe></div>