問題描述
查詢數據時應該使用 MongoTemplate 還是 DBCollection (Should i use MongoTemplate or DBCollection when query data)
[Java Spring] 目前我正在使用MongoTemplate查詢數據
MongoTemplate ‑‑> return List
mongoTemplate.find(query , 實體)
DbCollection ‑‑> return DbCursor
dbCollection.find()
那我應該用什麼來最好的方法
參考解法
方法 1:
since your application is a spring application i would suggest to stick with mongotemplate as it is springframework provided class and can go along well with other spring features. whereas DBcollection is a class from mongo API for java and there might be some cases where you have to play around to get your stuff done.
(by Phong Nguyen、satish chennupati)