Is it possible to avoid cast warnings after using createQuery().list?
//Type safety: The expression of type List needs unchecked conversion to conform to Lis
You can avoid the warnings if you use an EntityManager, but not sure if it makes things any nicer:
EntityManager em = provider.get(); // your code will probably be different here
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery query = builder.createQuery(type); // your Class
Root root = query.from(type); // your Class
query.select(root);
TypedQuery typedQuery = em.createQuery(query);
typedQuery.getResultList(); // List
Edit: obviously, there are nicer ways of setting this out...