Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @param <IMPL_TYPE> implention of the Model
- * @param <INT_TYPE> interface of the Model
- */
- public class GenericDAOI<IMPL_TYPE extends INT_TYPE , INT_TYPE> implements GenericDAO<INT_TYPE> {
- private EntityManager em;
- private Class<INT_TYPE> interfaceType;
- private Class<IMPL_TYPE> implType;
- public GenericDAOI(EntityManager em, Class<IMPL_TYPE> tType, Class<INT_TYPE> sType) {
- this.em = em;
- this.implType = tType;
- this.interfaceType = sType;
- }
- @Override
- public INT_TYPE findById(Long id) {
- INT_TYPE elem = em.find(implType, id);
- return elem;
- }
- @Override
- public List<INT_TYPE> findAll() {
- String sqlQueryAll = "FROM " + implType.getName();
- return em.createQuery(sqlQueryAll, interfaceType).getResultList();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement