title: Spring Data JPA JPQL queries on parent interface
body: <p>Say I have a <code>@MappedSuperClass</code> like this:</p>
  
  <pre><code>@MappedSuperclass
  public abstract class Rating
  {
      @Id
      private Long id;
  
      @Column(name="USER_ID")
      private Long userId;
  
      private int rating;
      ...
  </code></pre>
  
  <p>With a concrete child entity like this</p>
  
  <pre><code>@Entity
  @Table(name="ACTIVITY_RATING")
  public class ActivityRating extends Rating
  {
      private Long activitySpecificData;
      ...
  </code></pre>
  
  <p>Then there is a Spring Data JPA repository like this:</p>
  
  <pre><code>@NoRepositoryBean
  public interface RatingRepository&lt;R extends Rating&gt; extends JpaRepository&lt;R, ID&gt;
  {
      public List&lt;R&gt; findByUserId(Long userId);
      ...
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>public interface ActivityRatingRepository extends RatingRepository&lt;ActivityRating&gt;
  {
  
  }
  </code></pre>
  
  <p>This all works great and I can call <code>findByUserId()</code> on any of specific rating repositories that extend <code>RatingRepository</code>. I am now wanting to write some JPQL in the <code>RatingRepository</code> that all the child interfaces can inherit. I just don't know what (or if it's even possible) to put after the <code>FROM</code> in the query. For example:</p>
  
  <pre><code>@Query("SELECT NEW com.foo.RatingCountVo(e.rating, COUNT(e.rating)) FROM ??????? e GROUP BY e.rating")
  public List&lt;RatingCountVo&gt; getRatingCounts();
  </code></pre>
  
  <p>I can add this method to each of the individual repositories that extend <code>RatingRepository</code> but everything would be exactly the same except for the specific entity name. If I want to change the query, I'd then have to go to all the child repositories and update them individually. I really want the query to live in the parent class and not be duplicated. Is there any way to accomplish this?</p>
  
  <p>I'm currently using spring-data-jpa 1.7.2 and eclipselink 2.5.2. I'm not necessarily opposed to switching to newer versions if necessary.</p>