Spring data mongo uses @DBRef to query the set of specified fields.

  mongodb, question

图片描述

I need to query the Archive table to obtain the result set of Archive.title and User.name fields (on demand). what can I do? I can’t find the answer, please give me some advice, thank you!

Mongodb does not support join, and your dbref is not lazy loading mode, so user will be found when checking archive.
You can use query statements such as hibernate’s hsql to implement archive.title and archive.user, but you cannot query aechive.user.name alone.
Mongodb is a non-relational database, which encourages redundant fields and queries, so the situation you mentioned is really difficult to implement.