Hibernate or JPA or JDBC or? [closed]

Here’s my take: JPA: Agnostic way to do Java persistence without coupling your clients to Hibernate, TopLink, etc. Hibernate: Good choice if you have an object model to map to. JDBC: All Java persistence is built on this. Lowest level DAO: More of a pattern than a technology; CRUD operation interface. iBatis: Halfway between JDBC … Read more

JSF Controller, Service and DAO

Is this the correct way of doing things? Apart from performing business logic the inefficient way in a managed bean getter method, and using a too broad managed bean scope, it looks okay. If you move the service call from the getter method to a @PostConstruct method and use either @RequestScoped or @ViewScoped instead of … Read more

DAO, Repositories and Services in DDD

Repositories are – like you say – an abstraction. They originate from Martin Fowler’s Object Query Pattern. Both Repositories and DTOs can simplify database persistence by mapping persisted data to equivalent collection of entity objects. However, Repositories are more coarse-grained than DAOs by providing control of an entire Aggregate Root (AG) often hiding a lot … Read more

Java EE Architecture – Are DAO’s still recommended when using an ORM like JPA 2?

If I’m using an ORM like JPA2 – where I have my entities that are mapped to my database, should I still be using a DAO? It seems like a lot more overhead. It is. And clearly, Java EE doesn’t encourage using the DAO pattern when using JPA (JPA already provides a standardized implementation of … Read more

Single DAO & generic CRUD methods (JPA/Hibernate + Spring)

Here is an example interface: public interface GenericDao<T, PK extends Serializable> { T create(T t); T read(PK id); T update(T t); void delete(T t); } And an implementation: public class GenericDaoJpaImpl<T, PK extends Serializable> implements GenericDao<T, PK> { protected Class<T> entityClass; @PersistenceContext protected EntityManager entityManager; public GenericDaoJpaImpl() { ParameterizedType genericSuperclass = (ParameterizedType) getClass() .getGenericSuperclass(); this.entityClass … Read more