title: Hibernate HQL : no entity found for query
body: <p>It spent a day trying solve this problem however it's still not successful.
  I have <strong>Test entity</strong> :</p>
  
  <pre><code>public class Test {
  @Id
  @Column(name = "id")
  @GeneratedValue(strategy = GenerationType.AUTO)
  private long id;
  @Column(name = "duration", nullable = false)
  private int duration;
  @Column(name = "test_name", nullable = false, unique = true)
  private String testName;
  @Column(name = "archived", nullable = false)
  private boolean archived;
  @OneToMany(cascade = CascadeType.ALL, mappedBy = "test", fetch = FetchType.EAGER)
  private Set&lt;Question&gt; questions;
  @ManyToMany(mappedBy = "tests")
  private Set&lt;User&gt; users;
  </code></pre>
  
  <p>This <strong>Test entity</strong> has <strong>Set of questions</strong>, in such way <strong>Question Entity</strong> has <strong>Set of answers</strong>. </p>
  
  <p>I wrote  HQL query to get test:</p>
  
  <pre><code> @NamedQuery(name = "getCurrentTestById",
              query = "SELECT test From Result result JOIN result.test test JOIN result.user user " +
                      "JOIN test.questions question JOIN question.answers answer " +
                      "WHERE test.id = :testId AND user.id = :userId " +
                      "AND result.permission.id = :permissionId AND question.isArchived = false AND answer.isArchived = false")
  </code></pre>
  
  <p><strong>My DAO</strong>:</p>
  
  <pre><code>    public Test getCurrentTest(long id, long testId, long permissionId){
      Query query = em.createNamedQuery("getCurrentTestById");
      query.setParameter("userId", id);
      query.setParameter("testId", testId);
      query.setParameter("permissionId", permissionId);
      return (Test)query.getSingleResult();
  }
  </code></pre>
  
  <p>So, everything is OK until i set any Question or Answer as "archived". <strong>I am still getting all of them, even if they are archived</strong>. Moreover, if i will mark all Set of questions\answers for current test as archived - i will get exception : <strong>no entity found for query</strong> </p>