MongoDB projection difference between 5.3 and 5.4


We have some code written using OGM 5.3 that does not work in 5.4. A good example can be found in your tests at [1]. In OGM 5.3 createNativeQuery will allow you to specify a query string with projection and a class (ex. EntityManager.createNativeQuery(“db.Movie.find( {}, { ‘year’ : 1, ‘author’ : 1 } )”, Movie.class). In OGM 5.4 an error is now returned saying that project and addEntity are not allowed together. Is this something that can be fixed?



The reason we don’t allow that behavior is that it might lead to entities where not all the fields are initialized and this can cause issues when running subsequent queries. This is the related JIRA:

Could you give us more information about your use case, please? What kind of queries are you running?