Skip to content

Allow to use repository query parameters to define a part of key in @Query [DATAMONGO-351] #1284

@spring-projects-issues

Description

@spring-projects-issues

Stanislav Tyurikov opened DATAMONGO-351 and commented

One of my entity contains a java.util.Map field. After persistence it is transformed to a document like this:

{ lang: 
  {
     Java: 1000,
     Groovy: 2000,
     Xml: 3000,
  }
}

lang is the name of the map field. "Java", "Groovy" and "XML" are keys in the map, 1000, 2000, 3000 - the values.

I want to create a query method on a repository instance to select documents which contain desirable key and value:

@Query(" { lang.?0 : ?1 } " )
MyEntity findByLangAndValue(String someLang, long someValue);

The problem is then parameters are mapped to a query to execute, ?0 is replaced with someLang's value arounded with quotes. i.e. call findByLangAndValue("Java", 1000) transformed to query: \{ lang.\"Java\" : "1000" \} which fails to execute. Arounding a key part with quotes looks like a bug. At least it makes impossible to create query such as in my case


No further details from DATAMONGO-351

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions