Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kdejaeger opened this issue Aug 24, 2023 · 7 comments
Assignees
Labels
in: query-parser Everything related to parsing JPQL or SQL type: regression A regression from a previous release

Comments

@kdejaeger
Copy link

kdejaeger commented Aug 24, 2023

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)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 24, 2023
@mp911de
Copy link
Member

mp911de commented Aug 25, 2023

We've tightened up our comparisons regarding parameter bindings. It seems that the checks for InParameterBinding are too strict and we should fix that regression.

@mp911de mp911de self-assigned this Aug 25, 2023
@mp911de mp911de added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 25, 2023
@mp911de mp911de changed the title Spring (boot) 3.1.3 regression? 'Already found parameter binding with same index' ParameterBindingParser fails with Already found parameter binding with same index Aug 25, 2023
@mp911de mp911de added this to the 3.0.10 (2022.0.10) milestone Aug 25, 2023
@mp911de mp911de added the in: query-parser Everything related to parsing JPQL or SQL label Aug 25, 2023
mp911de added a commit that referenced this issue Aug 25, 2023
…bound differently.

We now register a new parameter binding if the named/positional parameter is already bound in an incompatible style.

Closes #3126
mp911de added a commit that referenced this issue Aug 25, 2023
…bound differently.

We now register a new parameter binding if the named/positional parameter is already bound in an incompatible style.

Closes #3126
@mp911de
Copy link
Member

mp911de commented Aug 25, 2023

That's fixed now and part of the latest snapshots. Care to give it a try with 3.1.4-SNAPSHOT to see whether the fix works for you?

@kdejaeger
Copy link
Author

Yes it works, the error is gone now. Thank you.

@mp911de
Copy link
Member

mp911de commented Aug 31, 2023

Fix for regression out of #3041/#3083.

@HengCC
Copy link

HengCC commented Sep 1, 2023

@mp911de i've update to 3.1.4-snapshot , but problem still ,
#1230 (comment)

There is another issue where Hibernate updates the data types of many fields every time it starts. In fact, there have been no actual updates, and no updates are needed. I have replaced the dialect with 'dialect: org.hibernate.dialect.MySQLDialect.'

image

@HengCC
Copy link

HengCC commented Sep 4, 2023

After downgrading to version 3.0.9, the field updates mentioned above no longer repeat execution every time the application starts. and the error ParameterBindingParser fails with Already found parameter binding with the same index has also disappeared.

@mp911de i've update to 3.1.4-snapshot , but problem still , #1230 (comment)

There is another issue where Hibernate updates the data types of many fields every time it starts. In fact, there have been no actual updates, and no updates are needed. I have replaced the dialect with 'dialect: org.hibernate.dialect.MySQLDialect.'

image

@cec
Copy link

cec commented Apr 30, 2024

This is still broken in spring-data-jpa 3.2.3!

I spent 1 hour trying to understand what was going on.
In my case I used the short syntax of Postgres to cast (::integer instead of cast(value as integer))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: query-parser Everything related to parsing JPQL or SQL type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

5 participants