General J2EE: DAO or Database Layer Pattern ?

  1. DAO or Database Layer Pattern ? (5 messages)

    I need to choose between DAO pattern or database layer pattern.
    if i use DAO then i have to embed CRUD methods of my entities inside themselves.

    but if i choose a database layer(wrapper) pattern then i can have all my CRUD methods inside this layer and free my entities of CRUD functions.

    im not sure which one to use?

    Threaded Messages (5)

  2. DAO or Database Layer Pattern ?[ Go to top ]

    use an ORM tool like hibernate.

    DAO will wrap the hibernate/HQL calls.
  3. i should rename database layer pattern to persistence layer pattern.
    my problem is haveing CRUD methods in entities.
    they should be ported to another(lower) layer of abstraction.
  4. DAO does not tell us that you have to put all of your CRUD methods inside the entity objects. You may use value objects (or transfer objects as you like) to represent the persistent data and Data Access Objects to CRUD the value objects. The 'Core J2EE Patterns' book - DAO example demonstrate us the CRUD operations inside the DAO. BTW, why did you decided that you have to put all of your CRUDs into the entity object? And what do you call database layer pattern? As for me it is an 'old fashioned' DAO name. Any comments?

  5. RE: DAO or Database Layer Pattern ?[ Go to top ]

    well i've always used this pattern..example is with hibernate/spring

    -setters/getters for database record

    public class Table1DAOImpl
    extends HibernateDAOSupport
    implements Table1DAO

    public void save(Table1VaueObject table1VaueObject){

    public List loadAll(){

  6. RE: DAO or Database Layer Pattern ?[ Go to top ]

    getHibernateTemplate().find("select count(*) from table...etc..");

    is done in the DAOImpl