Closed
Description
The following scenario is not working as expected with version 4.4.1 - it was last working in version 4.3.7
We have an entity which contains a MongoDB "_id" field, an "id" field and other arbitrary fields. For example:
@Data
@Document(collection = "test")
public class MdbTest {
@Id
private String key;
private String id;
// ... other fields here
}
The find() operations in 4.4.1 are returning the data when filtering by the "id" field, but the value of the "id" field is always null.
In 4.3.7, the value of the "id" field is returned as expected.
Is this an intentional change in behavior?
Here is a small test replicating the scenario. The last assertion fails with version 4.4.1.
MdbTest record = new MdbTest();
record.setKey("123");
record.setId("ID 123");
Assertions.assertNotNull(record.getId());
mongoTemplate.save(record);
Query query = new Query(Criteria.where("id").is("ID 123"));
record = mongoTemplate.findOne(query, MdbTest.class);
Assertions.assertNotNull(record);
Assertions.assertNotNull(record.getId()); // THE TEST FAILS HERE!