Spring data mongodb repositories vs mongoTemplate?

2,577 views
Skip to first unread message

Abhi

unread,
May 5, 2014, 7:19:51 AM5/5/14
to mongod...@googlegroups.com
Hi,
I am using spring-data-mongodb to interact with mongodb instance in my application. I am new to spring data and nosql domain and am not sure whether to use spring data repositories or mongoTemplate to perform CRUD operations.

Which approach is recommended using repositories or mongoTemplate based on various factors like ease of use, performance, flexibility etc.?

Would love insights of people already using spring data and mongodb. Which approach did you follow?

Thanks,
Abhi

Paul Scott

unread,
May 5, 2014, 7:25:10 AM5/5/14
to mongod...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/05/2014 13:19, Abhi wrote:
> Hi, I am using spring-data-mongodb to interact with mongodb
> instance in my application. I am new to spring data and nosql
> domain and am not sure whether to use spring data repositories or
> mongoTemplate to perform CRUD operations.

For Spring based apps, use spring-data-mongodb. There is always an
option to override some of the things to use the base MongoTemplate as
well, but for the most part, Spring data will make your life easier.

- -- Paul

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTZ3UWAAoJEP7GEwhwShZxSEgIAKxvMvG3drm3vaoP7hmUXjjK
haF/fzST7D6chQDQB/EmCRMxQJ0utKoKCmNi6JbSVb2V0AzYN/HmMreMIPBCuZBT
l0NyBDMUvSqcVtglGeid0cBmUkT4k5LJ+ALX1rMavmMpD4QNIT2GlqqNRJ2rB7Y9
rTA64TwtCcI8zwLOGvUQm7BYZ7/ZxyUKUDOyScBncT/FzbWoNaMeMZu21S46ezs1
Ja+OxoiUltIZy8S8kD+nGrr7kaxZNRBVcErPfsUEw10aR/V+CVtSOVMzAju8nTPM
+UQJyTIM+LKW/Z5nqz5En4RqnhbrFDWl1UeWNKj1L7rLupPK7HfLgEahcYrjJXM=
=ZOtu
-----END PGP SIGNATURE-----

Abhi

unread,
May 5, 2014, 9:33:35 AM5/5/14
to mongod...@googlegroups.com
Hi,
I am using spring-data-mongodb. I just want to know which approach - Spring Data Mongo Repository or MongoTemplate is recommended? What approach is lacking what features.
For example MongoTemplate has a lot of different types of "save object" operations, like save, upsert, insert, and updateFirst whereas spring data's MongoRepository interface has one persistence method: "save".

I would like to know the approach recommended by experienced users or guidelines for choosing which approach in what situation?


Thanks,
Abhi
Reply all
Reply to author
Forward
0 new messages