How to return List<String> or String in Spring Data rest
<p>I am using Spring Data rest for my application.</p>

<p>I am using following method in my repository.</p>

<pre><code>public interface TestRepository() extends BaseRepository&lt;TestTerm, Integer&gt;{
    @Query("select distinct tt.term from TestTerm")
        List&lt;String&gt; findDistinctTerm();
}
</code></pre>

<p>When I execute the above method. I am getting following error</p>

<pre><code>PersistentEntity must not be null
</code></pre>

<p>Question related to <a href="https://stackoverflow.com/questions/33538426/spring-data-rest-sdr-bug-persistent-entity-must-not-be-null/33575327#comment67824619_33575327">Spring Data Rest (SDR ) bug? Persistent Entity Must not be null</a></p>

<p>How can I resolve this ?</p>

<p>Do I have to write separate implementation for this ? If so Anyone provide me example for this ?</p>

<p><strong>Update:-</strong> </p>

<p>I have tried like this</p>

<p>Method 1:-</p>

<pre><code>@Query("select DISTINCT term from ForbiddenTerm")
List&lt;TestTerm&gt; findDistinctByTerm();
</code></pre>

<p>Error:-</p>

<p>{
  "cause": null,
  "message": "PersistentEntity must not be null!"
}</p>

<p>Method 2:-</p>

<pre><code>List&lt;TestTerm&gt; findDistinctByTerm();
</code></pre>

<p>Error:-</p>

<pre><code>    ... 154 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.repository.support.Repositories]: Factory method 'repositories' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'forbiddenTermRepository': Invocation of init method failed; nested exception is java.util.NoSuchElementException
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
    ... 175 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'forbiddenTermRepository': Invocation of init method failed; nested exception is java.util.NoSuchElementException
</code></pre>