This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Comment

It seems you're mixing up quite a few things here. MongoTemplate is a rather low level API that does not do any "target collection handling by entity class" as the API clearly indicates. You *can* specify a default collection, but don't have to. If you want to be specific about the collection to persist an entity just use one of the methods MongoTemplate provides that takes the specific collection.

The repository stuff is pretty much built on top of that. As we have a repository-per-entity model we also apply a "entity-name-to-collection-name" default. This is hidden behind the EntityMetadata/EntityInformation abstraction. So if you configure the MongoRepositoryFactoryBean a MappingContext, the settings you made in the @Document annotation should be regarded. The following namespace snippets should work as well: