title: Hibernate Filter is not applied for FindOne CRUD operation
body: <p>I do have this hibernate filter in my repository:</p>
  
  <pre><code>@Entity
  @Audited
  @DiscriminatorValue(value = "GROUP")
  @FilterDef(name = "groupACL", parameters = @ParamDef(name = "userId", type = "long"))
  @Filters({
      @Filter(name = "groupACL", condition = "app_group_id IN (SELECT DISTINCT APP_GROUP_ID FROM APP_GROUP START WITH APP_GROUP_ID IN (SELECT UG.APP_GROUP_ID FROM USER_GROUP UG JOIN APP_USER AU ON AU.APP_USER_ID = UG.APP_USER_ID WHERE USER_ID=:userId) CONNECT BY PARENT_APP_GROUP_ID = PRIOR APP_GROUP_ID)", deduceAliasInjectionPoints = false) })
  public class Group extends AbstractGroup {
  </code></pre>
  
  <p>It is triggered using Spring AOP with the following class:</p>
  
  <pre><code>@Component
  @Aspect
  public class ACLFilterAspect {
  private static final String GROUP_ACL = "groupACL";
  
  @Autowired
  private EntityManager em;
  
  @Before("execution(* com.trendshift.kyn.pug.data.GroupRepository.*(..))")
  public void forceFilter() {
      Session hibernateSession = em.unwrap(Session.class);
      ....
      hibernateSession.enableFilter(GROUP_ACL).setParameter("userId", userId);
      }
  }
  }
  </code></pre>
  
  <p>I finally have the following service:</p>
  
  <pre><code>@Service
  @Transactional(propagation = Propagation.REQUIRED)
  public class GroupServiceImpl implements GroupService {
  
    @Autowired
    GroupRepository groupRepository;
  
    @Override
    public Group findGroupById(long id) {
      Group group = groupRepository.findById(id);
      return group;
    }
  }
  </code></pre>
  
  <p>and these repositories:</p>
  
  <pre><code>@RepositoryRestResource(exported = false)
  public interface AbstractGroupRepository&lt;T extends AbstractGroup&gt;
      extends JpaRepository&lt;T, Long&gt;, QueryDslPredicateExecutor&lt;T&gt; {
  
  List&lt;T&gt; findByNameIgnoreCase(String name);
  
  List&lt;T&gt; findByNameAndTypeOrderByNameAsc(String name, String type);
  
  List&lt;T&gt; findByIdOrderByNameAsc(Long id);
  
  AbstractGroup findById(Long id);
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public interface GroupRepository
      extends AbstractGroupRepository&lt;Group&gt;, GroupRepositoryExtras {
  
  List&lt;Group&gt; findByNameAndCustomerId(String name, Long customerId);
  
  Iterable&lt;Group&gt; findByCustomerIdAndTypeIn(Long id, List&lt;String&gt; types);
  
  Group findById(long id);
  
  }
  </code></pre>
  
  <p>The issue is that when I use groupRepository.<strong>findById(id)</strong> the filter is correctly applied.</p>
  
  <p>If I use a CRUD core query groupRepository.<strong>findOne(id)</strong> the filter is not applied even after processing the Aspect hibernateSession.enableFilter(GROUP_ACL).setParameter("userId", userId);
  Even if Java enables the filter, the log file doesn't show any trace of the filter in the hibernate query.</p>
  
  <p>The problem seem to be only with the .findOne. findAll is working fine.</p>
  
  <p>Is there something in the Hibernate doc that says that you cannot applied a filter to findOne methods?</p>