protected TypedQuery<Contact> getSearchQuery(ContactSearchDTO contact) {
CriteriaBuilder criteriaBuilder = JPA.em().getCriteriaBuilder();
CriteriaQuery<Contact> criteriaQuery = criteriaBuilder.createQuery(entityClass);
Root<Contact> from = criteriaQuery.from(entityClass);
CriteriaQuery<Contact> select = criteriaQuery.select(from);
ParameterExpression fN = criteriaBuilder.parameter(String.class);
ParameterExpression lN = criteriaBuilder.parameter(String.class);
ParameterExpression mN = criteriaBuilder.parameter(String.class);
ParameterExpression date = criteriaBuilder.parameter(Date.class);
ParameterExpression mail = criteriaBuilder.parameter(String.class);
ParameterExpression city = criteriaBuilder.parameter(String.class);
ParameterExpression str = criteriaBuilder.parameter(String.class);
ParameterExpression house = criteriaBuilder.parameter(String.class);
ParameterExpression apart = criteriaBuilder.parameter(String.class);
if (contact.getBirthDate() != null) {
if (contact.getDirection().equals(">")) {
select.where(criteriaBuilder.like(from.get("firstName"), fN),
(criteriaBuilder.like(from.get("middleName"), mN)),
(criteriaBuilder.like(from.get("lastName"), lN)),