private < T , Y > TypedQuery < T > createTypedQueryIn ( Class < T > entityCls , SingularAttribute < T , Y > attribute , List < Y > values ) { 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 ) ; CriteriaBuilder . In < Y > in = builder . in ( path ) ; if ( values != null ) { for ( Y val : values ) { in . value ( val ) ; } } return entityManager . createQuery ( criteriaQuery . where ( in ) ) ; }
Creates a typed query for entities that match any of the specified values of the given attribute .