wherehows-dao/src/main/java/wherehows/dao/table/BaseDao.java
@SneakyThrows
  @SuppressWarnings("unchecked")
  public <T> List<T> findListBy(Class<T> entityClass, Map<String, ? extends Object> params) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    CriteriaBuilder cb = entityManager.getCriteriaBuilder();
    CriteriaQuery<T> criteria = cb.createQuery(entityClass);
    Root<T> entityRoot = criteria.from(entityClass);

    //Constructing list of parameters
    List<Predicate> predicates = new ArrayList<Predicate>();
    for (Map.Entry<String, ? extends Object> entry : params.entrySet()) {
      predicates.add(cb.equal(entityRoot.get(entry.getKey()), entry.getValue()));
    }

    criteria.select(entityRoot);
    criteria.where(predicates.toArray(new Predicate[]{}));
    try {
      return entityManager.createQuery(criteria).getResultList();
    } finally {
      entityManager.close();
    }
  }
/**
   * Find a list of entities by a parameter map
   * @param entityClass T.class the entity class type
   * @param params Map<String, Object>
   * @param <T> Entity type to find
   * @return List of entities
   */
Find a list of entities by a parameter map
@param entityClass T.class the entity class type
@param params Map
@param  Entity type to find
@return List of entities
Find a list of entities by a parameter map @param entityClass T . class the entity class type @param params Map @param Entity type to find @return List of entities
@SneakyThrows
  @SuppressWarnings("unchecked")
  public <T> List<T> findListBy(Class<T> entityClass, Map<String, ? extends Object> params) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    CriteriaBuilder cb = entityManager.getCriteriaBuilder();
    CriteriaQuery<T> criteria = cb.createQuery(entityClass);
    Root<T> entityRoot = criteria.from(entityClass);
    List<Predicate> predicates = new ArrayList<Predicate>();
    for (Map.Entry<String, ? extends Object> entry : params.entrySet()) {
      predicates.add(cb.equal(entityRoot.get(entry.getKey()), entry.getValue()));
    }
    criteria.select(entityRoot);
    criteria.where(predicates.toArray(new Predicate[]{}));
    try {
      return entityManager.createQuery(criteria).getResultList();
    } finally {
      entityManager.close();
    }
  }
@ SneakyThrows @ SuppressWarnings ( "unchecked" ) public < T > List < T > findListBy ( Class < T > entityClass , Map < String , ? extends Object > params ) { EntityManager entityManager = entityManagerFactory . createEntityManager ( ) ; CriteriaBuilder cb = entityManager . getCriteriaBuilder ( ) ; CriteriaQuery < T > criteria = cb . createQuery ( entityClass ) ; Root < T > entityRoot = criteria . from ( entityClass ) ; List < Predicate > predicates = new ArrayList < Predicate > ( ) ; for ( Map . Entry < String , ? extends Object > entry : params . entrySet ( ) ) { predicates . add ( cb . equal ( entityRoot . get ( entry . getKey ( ) ) , entry . getValue ( ) ) ) ; } criteria . select ( entityRoot ) ; criteria . where ( predicates . toArray ( new Predicate [ ] { } ) ) ; try { return entityManager . createQuery ( criteria ) . getResultList ( ) ; } finally { entityManager . close ( ) ; } }
Find a list of entities by a parameter map
 @param entityClass T.class the entity class type
 @param params Map<String, Object>
 @param <T> Entity type to find
 @return List of entities
Find a list of entities by a parameter map @param entityClass T . class the entity class type @param params Map<String Object > @param <T > Entity type to find @return List of entities
//Constructing list of parameters