title: use javax.persistence.Query in hibernate 4.2.3
body: <p>I use hibernate-4.2.3 and i will run my first <code>NamedQuery</code>. i create it as below:<br>
  <code>@NamedQuery(name="LoadUserWithEmail",query="select u from User u where email=:email")</code><br>
  after that i get it with <code>session.createNamedQuery</code>:  </p>
  
  <pre><code>        SessionFactory sessionFactory=SessionFactoryBuilder.build();
          Session session=sessionFactory.openSession();
          javax.persistence.Query query=  (javax.persistence.Query) session.getNamedQuery("LoadUserWithEmail");
          query.setParameter("email", email);
          User user=  (User) query.getSingleResult();  
  </code></pre>
  
  <p>but when i run this code i get following error:  </p>
  
  <pre><code>Exception in thread "main" java.lang.ClassCastException: org.hibernate.internal.QueryImpl cannot be cast to javax.persistence.Query
  at ir.sarresid.persistence.dao.UserDaoImpl.getWithEmail(UserDaoImpl.java:15)
  at ir.sarresid.persistence.test.PersonTest.getUser(PersonTest.java:51)
  at ir.sarresid.persistence.test.PersonTest.main(PersonTest.java:17) 
  </code></pre>
  
  <p>how i can solve it. i will not use org.hibernate.Query.<br>
  Do you have any solution. thanks.</p>