[Solved] The type CriteriaQuery is not generic;

[Solved] The type CriteriaQuery is not generic;

It is because of the incorrect import. CriteriaQuery is available in both hibernate and persistence package.

We have to import from persistence package in order to use criteriabuilder.

CriteriaQuery should be imported from

import javax.persistence.criteria.CriteriaQuery;

 

not from

import org.hibernate.criterion.CriteriaQuery;

 

Sample snippet:


@PersistenceContextprivate EntityManager em;

CriteriaBuilder cb = em.getCriteriaBuilder();

CriteriaQuery<AffiliateUrl> cq = cb.createQuery(AffiliateUrl.class);

Root<AffiliateUrl> from = cq.from(AffiliateUrl.class);

 

150 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *