简体   繁体   中英

Should i use MongoTemplate or DBCollection when query data

[Java Spring] At the moment, I'm using MongoTemplate to query data

  1. MongoTemplate --> return List

    mongoTemplate.find(query, entity)

  2. DbCollection --> return DbCursor

    dbCollection.find()

Then what should i use to best way

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM