Skip to content

SpringDataMongodbQuery and SpringDataMongodbSerializer apply mapping twice #4709

Closed
@bro0k

Description

@bro0k
# Entity class example
@Document(collection = "record")
public class Record {
    @Id
    private String id;

    @Field("embedded_object")
    private EmbeddedObject embeddedObject;
}

@Document(collection = "embedded_object")
public class EmbeddedObject {
    @Id
    private String id;
}

# Query code example
recordRepository.findAll(QRecord.record.embeddedObject.id.eq("64268a7b17ac6a00018bf312"), PageRequest.of(0,1))

# Expected correct result
find using query: { "embedded_object._id" : { "$oid" : "64268a6117ac6a00018bf30f"}} fields: Document{{}} 

# Actual incorrect result
find using query: { "embedded_object._id" : "64268a6117ac6a00018bf30f"} fields: Document{{}} 

Activity

changed the title [-]The createQueryFor(predicate) Method in QuerydslMongoPredicateExecutor Converts Query Conditions with Nested Objects Containing ObjectId() to Strings[/-] [+]`SpringDataMongodbQuery` and `SpringDataMongodbSerializer` apply mapping twice[/+] on May 28, 2024
mp911de

mp911de commented on May 28, 2024

@mp911de
Member

SpringDataMongodbSerializer used via QuerydslMongoPredicateExecutor applies field name customization twice. The resulting query above (used with the QueryMapper) is embedded_object._id while it should be embeddedObject.id. Removing field name mapping in SpringDataMongodbSerializer seems not enough as other components break.

added this to the 4.2.7 (2023.1.7) milestone on Jun 11, 2024
added 2 commits that reference this issue on Jun 11, 2024
4ca008d
bbef940
added 3 commits that reference this issue on Jun 11, 2024
added a commit that references this issue on Jun 11, 2024
8ffa40c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    `SpringDataMongodbQuery` and `SpringDataMongodbSerializer` apply mapping twice · Issue #4709 · spring-projects/spring-data-mongodb