title: JPA named Query getResultList() in generic way
body: <p>I want result list from JPA Named query in generic way like <code>List&lt;ProjectLevel&lt;?&gt;&gt;</code>. I need this as I wanted to stream it later.</p>
  
  <p><code>ProjectLevel</code> is a generic class.</p>
  
  <pre><code>public abstract class ProjectLevel&lt;T extends ProjectLevel&gt;{
  ....
  }
  </code></pre>
  
  <p>adding subClass of ProjectLevel as suggested.</p>
  
  <pre><code>@Entity
  @Getter
  @Setter
  @AllArgsConstructor(access = AccessLevel.PRIVATE)
  @NoArgsConstructor(access = AccessLevel.PUBLIC)
  @Table(uniqueConstraints = {
      @UniqueConstraint(columnNames = {"businessAccountId", "id"})})
  @NamedQueries({
      @NamedQuery(name = "Project.findByProjectIdOrUUID",
                  query = "SELECT p FROM Project p WHERE (p.id = :id OR p.uuid = :id) and p.businessAccountId = :businessAccountId")
  })
  public class Project extends ProjectLevel {
  
      private static final long serialVersionUID = 2167149510293504460L;
  
      @Nonnull
      private String customerUUID;
  
      @Nonnull
      @Enumerated(EnumType.STRING)
      private Currency currency;
  
      @Nonnull
      @Enumerated(EnumType.STRING)
      private ProjectType projectType;
  
      @Nonnull
      @Enumerated(EnumType.STRING)
      private ContractType contractType;
  
      @Nonnull
      private String cityLocation;
  
      private boolean locationPermission;
  
      private boolean insuranceRequired;
  }
  </code></pre>
  
  <p>I tried this but it gives me typecasting error like </p>
  
  <blockquote>
    <p>incompatible types: <code>List&lt;ProjectLevel&gt;</code> cannot be converted to
    <code>List&lt;ProjectLevel&lt;?&gt;&gt;</code> </p>
  </blockquote>
  
  <p>from getResultList() line</p>
  
  <pre><code>    public List&lt;ProjectLevel&lt;?&gt;&gt; findUUIDByNameorNumber(@Nonnull final String nameOrId,
                                                          @Nonnull final String businessAccountId) {
          checkNotNull(nameOrId, "The nameOrId must not be null");
  
          return (List&lt;ProjectLevel&lt;?&gt;&gt;)getEntityManager()
                  .createNamedQuery("ProjectLevel.findUUIDByNameOrId", ProjectLevel.class)
                  .setParameter("name", matchesFromBeginning(nameOrId))
                  .setParameter("businessAccountId", businessAccountId)
                  .getResultList();
      }
  </code></pre>
  
  <p>Any help would be appreciated.</p>