JPA made small revolution among ORM tools and EJB 2 world. Easy to use, simple unified way to develop you model and services. After i used it in few projects, i have found that all JPA services are very similar, so this is a simple try to generalize or template them. This can be for example simple abstract interface for all: package test . service ; import java.util.List ; public abstract interface JpaService < T > { void save ( T t ); T find ( Long id ); void remove ( Long id ); List < T > findAll (); long count (); } And abstract implementation class look like this: package test . service . impl ; import java.util.List ; import javax.persistence.EntityManager ; import javax.persistence.PersistenceContext ; import javax.persistence.Query ; import org.apache.log4j.Logger ; import test.service.JpaService ; public abstract class JpaServiceImpl < T > implements JpaService < T >{ /** Logger. */ ...
Sasa Jovancic, private blog