unicon.matthews.MongoConfig   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 16
rs 10
eloc 11
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A mongoConverter() 0 7 1
1
package unicon.matthews;
2
3
import org.springframework.beans.factory.annotation.Autowired;
4
import org.springframework.context.annotation.Bean;
5
import org.springframework.context.annotation.Configuration;
6
import org.springframework.data.mongodb.MongoDbFactory;
7
import org.springframework.data.mongodb.core.convert.DbRefResolver;
8
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
9
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
10
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
11
12
@Configuration
13
public class MongoConfig {
14
15
  @Autowired
16
  private MongoDbFactory mongoFactory;
17
18
  @Autowired
19
  private MongoMappingContext mongoMappingContext;
20
21
  @Bean
22
  public MappingMongoConverter mongoConverter() throws Exception {
0 ignored issues
show
Best Practice introduced by
Dedicated exceptions should be preferred over throwing the generic Exception.
Loading history...
23
    DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoFactory);
24
    MappingMongoConverter mongoConverter = new MappingMongoConverter(dbRefResolver, mongoMappingContext);
25
    //this is my customization
26
    mongoConverter.setMapKeyDotReplacement("_");
27
    return mongoConverter;
28
  }
29
}
30