0

i am totally new in mongo, i have learn mongo shell commands and now want to integrate mongo with java. in order to do this we have mongo client which is basic , for ease we have mongoTemplate and monggoRepositiry but what is difference between mongoTemplate and mongoRepository? i have read and tried to understand "What's the difference between Spring Data's MongoTemplate and MongoRepository?" but unable to get it.

Please tell me the difference in terms of benefit, drawbacks , methods , if there any relation between them or something other.

and one more question, spring data is mongoTemplate or mongoRepository?

shrikant.sharma
  • 203
  • 1
  • 17
  • 37
  • Possible duplicate of [What's the difference between Spring Data's MongoTemplate and MongoRepository?](https://stackoverflow.com/questions/17008947/whats-the-difference-between-spring-datas-mongotemplate-and-mongorepository) – Mihai Chelaru Jun 12 '18 at 13:50

1 Answers1

0

Edit

Duplicate of: What's the difference between Spring Data's MongoTemplate and MongoRepository?


From personnal experience, what I understand is that MongoRepository is used only for basic queries. If you need any operation other than find, you'll need to use MongoTemplate, which is complete enough to make all the operations possible in the mongo shell

Here you will find the documentation on MongoTemplate: https://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/MongoTemplate.html

After testing, it seems you can execute any mongo shell command, even the ones not documented, i.e. the distinct function.

Wissam Goghrod
  • 327
  • 1
  • 5
  • 15