title: Return custom-typed object from JpaRepository
body: <p>I have the following repository:</p>
  
  <pre><code>public interface UserRepository extends BaseDAO&lt;User&gt; {
      Collection&lt;User&gt; findByEmail(@Param("email") String email);
  
      @Query("select new com.data.CustomUser(upper(substring(u.lastName, 1, 1)) as initial, count(*)) from User u join u.chats c where c.business=:business group by upper(substring(u.lastName, 1, 1)) order by initial")
      List&lt;CustomUser&gt; getContactsIndex(@Param("email") String email);
  }
  </code></pre>
  
  <p>which is exposed with Spring Data REST. The <code>User</code> object is a managed entity, while <code>CustomUser</code> not and as you can see, it's build on-fly by using custom query.</p>
  
  <p>Once I want to call that function, it fails with <code>Persistent entity must not be a null!</code> exception. Is there any way to implement this behavior?</p>
  
  <p>P.S. Expose <code>CustomUser</code> with separate repository is impossible because it is not a managed entity.</p>