Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Dao Layer design

 
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a MVC pattern, the DAO is separate layer on the top of the bean. Most case is, we call dao.saveObject(MyBean) to persist an object.

In another design, we can omit the Dao layer, we can put the persistence logic inside the bean, then picture will be like this:



In these two designs, what is pro and cons, or they are same ? has transaction problem ?

Thanks.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Edward Chen wrote:

In another design, we can omit the Dao layer, we can put the persistence logic inside the bean



Putting the Persistence logic inside Bean is not advisable, it is against the SRP(Single responsibility Principle), and if persistence strategy changes tomorrow you have to modify your bean also, Persistence logic should be hidden to Beans.
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Gokul Nanthakumar wrote: and if persistence strategy changes tomorrow you have to modify your bean also



Don't understand this. In DAO, persistence logic changes, we still need to change DAO, the only difference is, we change functions inside a bean or inside a DAO. Could you please have an example to detail your point ?

Thanks for your inputs.
 
Gokul Nanthakumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Refer DAO Design Pattern, if Persistence logic changes you should not change in the existing DAO class, you have to create new DAO class and connect that to your Bean.
    Bookmark Topic Watch Topic
  • New Topic