Jun 6, 2017

[HDGEM] JPA offers polymorphic queries

JPA offers polymorphic queries

For example a findAll DAO method can be implemented as follows:

@Override
public List<T> findAll() {
CriteriaBuilder builder = entityManager
.getCriteriaBuilder();

CriteriaQuery<T> criteria = builder
.createQuery( entityClass );
criteria.from( entityClass );

return entityManager
.createQuery( criteria )
.getResultList();
}

--
Posted By Blogger to HDGEM at 6/06/2017 12:46:00 AM