How to use DAOs with hibernate/jpa?

Posted by Ari on Stack Overflow See other posts from Stack Overflow or by Ari
Published on 2010-04-16T21:59:01Z Indexed on 2010/04/16 22:03 UTC
Read the original article Hit count: 396

Filed under:
|
|

Assuming the DAO structure and component interaction described below, how should DAOs be used with persistence layers like hibernate and toplink? What methods should/shouldn't they contain?

Would it be bad practice to move the code from the DAO directly to the service?

For example, let's say that for every model we have a DAO (that may or may not implement a base interface) that looks something like the following:

public class BasicDao<T> {
 public List<T> list() { ... }
 public <T> retrieve() { ... }
 public void save() { ... }
 public void delete() { ... }
}

Component interaction pattern is --

service > DAO > model

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about data-access-layer