我需要查询Archive表,获取Archive.title和User.name字段的结果集(按需),请问可以怎么操作?没找到答案,请指点一二,谢谢!
伊谢尔伦2017-04-28 09:08:08
Mongodb does not support join, and your dbref is not in lazy loading mode, so when checking the archive, the user will also be found.
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 field redundancy and query redundancy, so the situation you mentioned is really difficult to implement
某草草2017-04-28 09:08:08
@Query(value = "{'id':?0, 'disabled':false}", fields = "{'$id':1, 'success_ret_codes':1}")
Stream findSuccessRetCodes(String streamId);
Using the fields above, only one field can be missing, and the other fields are null.
But the data of the joint table cannot be queried, because the Archive table stores the ID and table name of the joint table, so only the ID can be found here. , I tested it and directly checked the name of the joint table and reported an error. So, that’s it.
怪我咯2017-04-28 09:08:08
I encountered the same problem as you. I haven’t found a way to get only some fields in some DBRef objects. Same solution.
For your problem, you can try the method in this article. My problem is a little more complicated than yours:
http://blog.csdn.net/congcong...