Skip to content

@Query Annotation Placeholder Issue [DATAMONGO-1603] #2514

Closed
@spring-projects-issues

Description

@spring-projects-issues

Philipp Etschel opened DATAMONGO-1603 and commented

With the 1.10 release queries that use the same parameters more than once do not work any more.

Example:

@Query("{ $or: [ { user.name: ?0 }, { user.nickname: ?0 } ] }")
User findByUserNameOrNickname(String name);

Executed this will result in a JSONParseException

com.mongodb.util.JSONParseException: 
{ $or: [ { user.name: "foo" }, { user.nickname: "foo"0 } ] }

I have narrowed it down to ExpressionEvaluatingParameterBinder.extractPlaceholder() where the second call to resolve the second parameter returns ?00 instead of ?0 resulting in the trailing 0.

If I rewrite the example to:

@Query("{ $or: [ { user.name: ?0 }, { user.nickname: ?1 } ] }")
User findByUserNameOrNickname(String name, String nickname);

It works again


Affects: 1.10 GA (Ingalls)

Issue Links:

  • DATAMONGO-1604 String replacement values correctly only for the first string
    ("duplicates")
  • DATAMONGO-1622 Regex Query execution changed after release 1.9.6

Referenced from: pull request #441

Backported to: 1.10.1 (Ingalls SR1), 1.9.8 (Hopper SR8)

1 votes, 6 watchers

Metadata

Metadata

Labels

in: coreIssues in core supporttype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions