@Override
 public List<T> findByExample(final T entity, final SearchParameters sp) {
   Assert.notNull(sp, "Search parameters required");
   if (sp.hasNamedQuery()) {
     return getNamedQueryUtil().findByNamedQuery(sp);
   }
   Specifications<T> spec =
       Specifications.where(byExampleEnhancedSpecification.byExampleOnEntity(entity, sp));
   return findAll(spec);
 }
  @Override
  public long countByExample(final T entity, final SearchParameters sp) {
    Validate.notNull(entity, "The entity cannot be null");
    if (sp.hasNamedQuery()) {
      return getNamedQueryUtil().numberByNamedQuery(sp).intValue();
    }
    Specifications<T> spec =
        Specifications.where(byExampleEnhancedSpecification.byExampleOnEntity(entity, sp));

    return super.count(spec);
  }