private < T , Y > TypedQuery < T > createTypedQuery ( Class < T > entityCls , SingularAttribute < T , Y > attribute , Y value ) { EntityManager entityManager = this . entityManagerProvider . get ( ) ; CriteriaBuilder builder = entityManager . getCriteriaBuilder ( ) ; CriteriaQuery < T > criteriaQuery = builder . createQuery ( entityCls ) ; Root < T > root = criteriaQuery . from ( entityCls ) ; Path < Y > path = root . get ( attribute ) ; return entityManager . createQuery ( criteriaQuery . where ( builder . equal ( path , value ) ) ) ; }
Creates a typed query for entities that have the given attribute value .