title: Spring Data Rest executes query but returns 500 internal Server Error
body: <p>I am using spring boot and spring data rest and I am facing a 500 internal server error, but no messages are displayed in console.</p>
  <p>I have the following:</p>
  <p>ProdutoVendaRepository.java</p>
  <pre><code>public interface ProdutoVendaRepository extends PagingAndSortingRepository&lt;ProdutoVenda, Integer&gt; {
  
  @Query(&quot;SELECT new br.com.contoso.model.VendaPorFamilia(b.nome, SUM(i.valorMultiplicado)) FROM ProdutoVenda i JOIN i.produto o JOIN o.familia b WHERE b.nome LIKE 'foo' GROUP BY b.nome&quot;)
  List &lt;VendaPorFamilia&gt; teste();
  }
  </code></pre>
  <p>VendaPorFamilia.java</p>
  <pre><code>public class VendaPorFamilia {
  
  private String nome;
  
  private double valorTotal;
  
  public VendaPorFamilia(String nome, double valorTotal) {
      this.nome = nome;
      this.valorTotal = valorTotal;
  }
  
  //getters and setters
  </code></pre>
  <p>ProdutoVenda.java</p>
  <pre><code>@Entity
  @Immutable
  @Table(name = &quot;INV1&quot;)
  public class ProdutoVenda {
  
  @Id
  @Column(name = &quot;LineNum&quot;)
  private int id;
  
  @Column(name = &quot;ItemCode&quot;)
  private String codigo;
  
  @Column(name = &quot;Quantity&quot;)
  private double quantidade;
  
  @Column(name = &quot;Price&quot;)
  private double precoUnitario;
  
  @Column(name = &quot;LineTotal&quot;)
  private double valorMultiplicado;
  
  @Column(name = &quot;Dscription&quot;)
  private String descricao;
  
  @OneToOne
  @JoinColumn(name = &quot;ItemCode&quot;, updatable = false, insertable = false)
  private Produto produto;
  
  //getters and setters
  </code></pre>
  <p>When I try to</p>
  <pre><code>curl -v  -X GET -H &quot;X-AUTH-TOKEN: TokenFoo&quot;  
  http://localhost:8080/api/produtoVendas/search/teste
  </code></pre>
  <p>The log shows that the query was executed:</p>
  <pre><code>2015-06-16 17:05:45.884 DEBUG 7892 --- [http-nio-8080-exec-1]         org.hibernate.SQL                        
  : select familia2_.ItmsGrpNam as col_0_0_, sum(produtoven0_.LineTotal) as col_1_0_ from 
  INV1 produtoven0_ inner join OITM produto1_ on produtoven0_.ItemCode=produto1_.ItemCode 
  inner join OITB familia2_ on produto1_.ItmsGrpCod=familia2_.ItmsGrpCod where    
  familia2_.ItmsGrpNam like 'foo' group by familia2_.ItmsGrpNam
  </code></pre>
  <p>But I receive a:</p>
  <pre><code>&lt; HTTP/1.1 500 Internal Server Error
  * Server Apache-Coyote/1.1 is not blacklisted
  &lt; Server: Apache-Coyote/1.1
  &lt; Content-Length: 0
  &lt; Date: Tue, 16 Jun 2015 20:05:46 GMT
  &lt; Connection: close
  &lt; 
  * Closing connection 0
  </code></pre>
  <p>I don´t know what to do, I´ve tried a lot of things but nothing seems to work.
  And Yes, when I execute the exact same generated query in MsSQL server, it returns the wanted value.
  All other repositories work without problems...</p>
  <p>Thanks for your time and help!</p>
  <h1>EDIT: The debug  log shows the folllowing:</h1>
  
  <pre class="lang-html prettyprint-override"><code>2015-06-17 15:25:58.670 DEBUG 8667 --- [http-nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/api/produtoVendas/search/teste]
  2015-06-17 15:25:58.674 DEBUG 8667 --- [http-nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /api/produtoVendas/search/teste
  2015-06-17 15:25:58.678 DEBUG 8667 --- [http-nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/api/produtoVendas/search/teste]
  2015-06-17 15:25:58.692 DEBUG 8667 --- [http-nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Last-Modified value for [/api/produtoVendas/search/teste] is: -1
  2015-06-17 15:25:58.758 DEBUG 8667 --- [http-nio-8080-exec-1] org.hibernate.SQL                        : select familia2_.ItmsGrpNam as col_0_0_, sum(produtoven0_.LineTotal) as col_1_0_ from INV1 produtoven0_ inner join OITM produto1_ on produtoven0_.ItemCode=produto1_.ItemCode inner join OITB familia2_ on produto1_.ItmsGrpCod=familia2_.ItmsGrpCod where familia2_.ItmsGrpNam like ‘foo’ group by familia2_.ItmsGrpNam
  2015-06-17 15:25:58.836 DEBUG 8667 --- [http-nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolving exception from handler [public org.springframework.http.ResponseEntity&lt;java.lang.Object&gt; org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.web.context.request.WebRequest,java.lang.String,org.springframework.data.rest.webmvc.support.DefaultedPageable,org.springframework.data.domain.Sort,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler)]: java.lang.IllegalArgumentException: PersistentEntity must not be null!
  2015-06-17 15:25:58.839 DEBUG 8667 --- [http-nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Invoking @ExceptionHandler method: org.springframework.http.ResponseEntity&lt;org.springframework.data.rest.webmvc.support.ExceptionMessage&gt; org.springframework.data.rest.webmvc.RepositoryRestExceptionHandler.handleMiscFailures(java.lang.Exception)
  2015-06-17 15:25:58.856 DEBUG 8667 --- [http-nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
  2015-06-17 15:25:58.857 DEBUG 8667 --- [http-nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Successfully completed request
  </code></pre>