title: IllegalArgumentException: Type specified for TypedQuery [model.User] is incompatible with query return type [class model.User]
body: <p>I am getting this intermittent error while creating a TypedQuery for Generic type. My method is as:</p>
  
  <pre><code>    public List&lt;T&gt; findByEmail(Class type, String email_id){
          String query = "SELECT t FROM " + type.getSimpleName() + " t WHERE t.email =:"+email_id;
          TypedQuery&lt;T&gt; typedQuery =em.createQuery(query, type);
          return (List&lt;T&gt;) typedQuery.getResultList();            
     }
  </code></pre>
  
  <p>While if I restart the server, the error doesn't reappear and it correctly fetch result. </p>
  
  <pre><code>play.api.Application$$anon$1: Execution exception[[IllegalArgumentException: Type specified for TypedQuery [model.User] is incompatible with query return type [class model.User]]]
              at play.api.Application$class.handleError(Application.scala:296) ~[play_2.11-2.3.7.jar:2.3.7]
              at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.11-2.3.7.jar:2.3.7]
              at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun
      $applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.7.jar:
      2.3.7]
              at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun
      $applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.7.jar:2.3.7]
              at scala.Option.map(Option.scala:145) [scala-library-2.11.1.jar:na]
      Caused by: java.lang.IllegalArgumentException: Type specified for TypedQuery [model.User] is incompatible with query return type [class model.User]
              at org.hibernate.jpa.spi.AbstractEntityManagerImpl.resultClassChecking(AbstractEntityManagerImpl.java:387) ~[hibernate-entitymanager-4.3.6.Final.jar:4.3.6.Final]
              at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractE
      ntityManagerImpl.java:344) ~[hibernate-entitymanager-4.3.6.Final.jar:4.3.6.Final
      ]
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.
      0_25]
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:62) ~[na:1.8.0_25]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:43) ~[na:1.8.0_25]
  </code></pre>