title: Spring DATA JPA with Java 8 Stream NonUniqueResultException
body: <p>I defined a repository based on PagingAndSortingRepository to have the below query implementation</p>
  
  <pre><code>@Query(" SELECT me FROM CustomerModelEntity me WHERE  me.planNum = :planNum AND me.customerModelStatusCode IN ('AVL','PHO')" +
          " AND me.modelCode IN (SELECT e.modelCode FROM ModelEntity e WHERE e.modelStatusCode IN ('AVL','PHO'))")
  Stream&lt;CustomerModelEntity&gt; findByPlanNum(@Param("planNum") String planNum);
  </code></pre>
  
  <p>The result is expected to have multiple results. But, the result came out to be an exception as below</p>
  
  <pre><code>Caused by: javax.persistence.NonUniqueResultException: result returns more than one elements
      at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:505) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
      at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:202) [spring-data-jpa-1.7.2.RELEASE.jar:]
      at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:74) [spring-data-jpa-1.7.2.RELEASE.jar:]
      at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:97) [spring-data-jpa-1.7.2.RELEASE.jar:]
      at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:88) [spring-data-jpa-1.7.2.RELEASE.jar:]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:395) [spring-data-commons-1.9.2.RELEASE.jar:]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:373) [spring-data-commons-1.9.2.RELEASE.jar:]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$DefaultMethodInvokingMethodInterceptor.invoke(RepositoryFactorySupport.java:486) [spring-data-commons-1.9.2.RELEASE.jar:]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) [spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) [spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) [spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      ... 125 more
  </code></pre>
  
  <p>The same @Query implementation works good if I have List instead of a Stream</p>
  
  <pre><code>@Query(" SELECT me FROM CustomerModelEntity me WHERE  me.planNum = :planNum AND me.customerModelStatusCode IN ('AVL','PHO')" +
          " AND me.modelCode IN (SELECT e.modelCode FROM ModelEntity e WHERE e.modelStatusCode IN ('AVL','PHO'))")
  List&lt;CustomerModelEntity&gt; findByPlanNum(@Param("planNum") String planNum);
  </code></pre>
  
  <p>Is it safe to assume that Java 8 support is not complete in Spring Data JPA/ am I doing something wrong here?</p>