Using Stream as result of a query method failed due to expecting a singular result
See original GitHub issueDespite what https://www.baeldung.com/spring-data-java-8 says, when I created a Stream<Foo>
on a org.springframework.cloud.gcp.data.datastore.repository.DatastoreRepository
implementation, I received this:
org.springframework.cloud.gcp.data.datastore.core.mapping.DatastoreDataException: The query method returns a singular object but the query returned more than one result.
at org.springframework.cloud.gcp.data.datastore.repository.query.GqlDatastoreQuery.convertSingularResult (GqlDatastoreQuery.java:227)
at org.springframework.cloud.gcp.data.datastore.repository.query.GqlDatastoreQuery.execute (GqlDatastoreQuery.java:156)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke (RepositoryMethodInvoker.java:137)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke (RepositoryMethodInvoker.java:121)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke (QueryExecutorMethodInterceptor.java:152)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke (QueryExecutorMethodInterceptor.java:131)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke (ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke (JdkDynamicAopProxy.java:215)
at com.sun.proxy.$Proxy104.getValidCarrierDirections (Unknown Source)
- some investigation led me to
org.springframework.data.repository.query.QueryMethod.isCollectionQuery()
- then to
org.springframework.data.repository.query.QueryMethod.calculateIsCollectionQuery()
- then to
org.springframework.data.util.TypeDiscoverer.isCollectionLike()
Shouldn’t that list include java.util.stream.Stream
?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Npgsql Exception while reading from stream, Postgres
I tried re-arranging the SQL to take out the sub-SELECTS and make them all joins; didn't help, same error. Here is the C#...
Read more >Automated Re-fetching | Redux Toolkit
If cache data is being invalidated, it will either refetch the providing query (if components are still using that data) or remove the...
Read more >Spring Data R2DBC - Reference Documentation
Limiting Query Results. You can limit the results of query methods by using the first or top keywords, which you can use interchangeably....
Read more >Debugging errors - dbt Developer Hub
In some cases, these errors might occur as a result of queries that dbt runs "behind-the-scenes". These include: Introspective queries to list ...
Read more >Solutions Engineer Senior Developer/Database ... - Ben Gribaudo
Streaming, query folding, buffering, table keys, native query caching and the firewall—all of these relate to how the interpreter thinks about/processes/handles ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Iterable is the lowest common denominator across the collection framework. We’re actually considering to retrofit
CrudRepository
with Spring Data 3.0 to returnList
to make it easier to consumefindAll
and other methods returning collections.Well, I was lucky then, to have worked mostly with projects where Iterable meant a streaming result. I mean without that extra functionality why would anybody return an Iterable, when you cuold just return a Collection/List instead?