Skip to content

ParameterBindingParser fails with Already found parameter binding with same index #3126

@kdejaeger

Description

@kdejaeger

Just checked out the release and some unit tests fail.

    @Query("SELECT DISTINCT x FROM X x WHERE (COALESCE(:locations) is null OR x.org.id IN :locations)" +
    Set<BLABLA> findABC(@Param("locations") Set<Long> locations);
Caused by: java.lang.IllegalArgumentException: Already found parameter binding with same index / parameter name but differing binding type; Already have: ParameterBinding [identifier: locations, origin: MethodInvocationArgument[identifier=locations]], found ParameterBinding [identifier: locations, origin: MethodInvocationArgument[identifier=locations]]; If you bind a parameter multiple times make sure they use the same binding
	at org.springframework.util.Assert.isTrue(Assert.java:122)
	at org.springframework.data.jpa.repository.query.StringQuery$ParameterBindingParser.lambda$checkAndRegister$8(StringQuery.java:394)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.springframework.data.jpa.repository.query.StringQuery$ParameterBindingParser.checkAndRegister(StringQuery.java:394)
	at org.springframework.data.jpa.repository.query.StringQuery$ParameterBindingParser.lambda$parseParameterBindingsOfQueryIntoBindingsAndReturnCleanedQuery$0(StringQuery.java:242)
	at org.springframework.data.jpa.repository.query.StringQuery$ParameterBindings.register(StringQuery.java:545)
	at org.springframework.data.jpa.repository.query.StringQuery$ParameterBindingParser.parseParameterBindingsOfQueryIntoBindingsAndReturnCleanedQuery(StringQuery.java:308)

Metadata

Metadata

Assignees

Labels

in: query-parserEverything related to parsing JPQL or SQLtype: regressionA regression from a previous release

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions