Join Annotation Does Not Change MongoDB Query
Expected Behavior
By default, a find query should be generated by the repository interface. According to the documentation (https://micronaut-projects.github.io/micronaut-data/latest/guide/#mongoJoinQueries), using the Join annotation switches to the aggregation pipeline to populate relationship fields.
Actual Behaviour
It doesn't.
@MongoRepository
public interface StarSystemRepository extends CrudRepository<StarSystem, Integer> {
}
and
@MongoRepository
public interface StarSystemRepository extends CrudRepository<StarSystem, Integer> {
@Override
@Join("stars")
@NonNull List<StarSystem> findAll();
}
generates an identical find query.
{"find": "starSystems", "filter": {"_id": {"$eq": 867158537}}, "limit": 1, "singleBatch": true, "$db": "pezdb", "lsid": {"id": {"$binary": {"base64": "qKkxNgeFTdi4SwSSwNvnHA==", "subType": "04"}}}}
The aggregation pipeline is never called, so objects are never populated. Placing the Join annotation in other places (under the Relationship, creating a non-Override interface method, etc.) also never stop the generation of that same find query. The related object is never populated.
Steps To Reproduce
No response
Environment Information
No response
Example Application
No response
Version
4.4.4
This is supposed to work, we have number of tests with joined entities in MongoDB. Here is attached example app with test with joined entity mn-mongo-join.zip
Please take a look and maybe create reproducer with your example.