-
Notifications
You must be signed in to change notification settings - Fork 617
Closed
Labels
type: bugA general bugA general bug
Description
It seems to raise an exception when a provided parameter is an empty iterable (I have only tried with Set
actually, but looking at the code that raises the error, it's likely the same thing with all Iterable<?>
).
Given the following example (the database does not actually matter)
interface TestPersonRepository : Neo4jRepository<PersonEntity, String> {
@Query(
"""
MATCH (person:Person) WHERE person.email IN $${"emails"} OR person.name IN $${"names"}
RETURN person
"""
)
fun findAllByNamesOrEmail(names: Set<String>, emails: Set<String>) : List<PersonEntity>
}
@Service
class TestService(
private val repository: TestPersonRepository
) {
init {
repository.findAllByNamesOrEmail(emptySet(), setOf("potato"))
}
}
I have the following stacktrace
Caused by: java.lang.IllegalArgumentException: Type must not be null!
at org.springframework.util.Assert.notNull(Assert.java:201)
at org.springframework.data.mapping.context.AbstractMappingContext.hasPersistentEntityFor(AbstractMappingContext.java:211)
at org.springframework.data.neo4j.repository.query.Neo4jQuerySupport.convertParameter(Neo4jQuerySupport.java:190)
at org.springframework.data.neo4j.repository.query.Neo4jQuerySupport.convertParameter(Neo4jQuerySupport.java:160)
at org.springframework.data.neo4j.repository.query.StringBasedNeo4jQuery.lambda$bindParameters$8(StringBasedNeo4jQuery.java:218)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.data.neo4j.repository.query.StringBasedNeo4jQuery.bindParameters(StringBasedNeo4jQuery.java:213)
at org.springframework.data.neo4j.repository.query.StringBasedNeo4jQuery.prepareQuery(StringBasedNeo4jQuery.java:180)
at org.springframework.data.neo4j.repository.query.AbstractNeo4jQuery.execute(AbstractNeo4jQuery.java:84)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
// ...
The error actually seem to be in org.springframework.data.neo4j.core.TemplateSupport.findCommonElementType
which returns a null
class when the collection is empty.
I'm testing using the latest 6.1.2
. Hope this helps!
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug