public < T extends HistoricalEntity < ? > , Y > List < T > getCurrentListByAttribute ( Class < T > historicalEntityCls , SingularAttribute < T , Y > attribute , Y value ) { EntityManager entityManager = this . entityManagerProvider . get ( ) ; CriteriaBuilder builder = entityManager . getCriteriaBuilder ( ) ; CriteriaQuery < T > criteriaQuery = builder . createQuery ( historicalEntityCls ) ; Root < T > root = criteriaQuery . from ( historicalEntityCls ) ; Predicate whereClause = builder . and ( builder . equal ( root . get ( attribute ) , value ) , expiredAt ( root , builder ) ) ; criteriaQuery . where ( whereClause ) ; TypedQuery < T > typedQuery = entityManager . createQuery ( criteriaQuery ) ; return typedQuery . getResultList ( ) ; }
Gets every instance of the specified historical entity in the database that has the given value of the given attribute .