From 984dd8bfdc337deca90ddf052d22184d58ef77e5 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Apr 2024 23:38:42 +0100 Subject: [PATCH] pls fix? --- .../xyz/mcutils/backend/config/MongoConfig.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/mcutils/backend/config/MongoConfig.java b/src/main/java/xyz/mcutils/backend/config/MongoConfig.java index 2bc2195..c1e0d31 100644 --- a/src/main/java/xyz/mcutils/backend/config/MongoConfig.java +++ b/src/main/java/xyz/mcutils/backend/config/MongoConfig.java @@ -1,8 +1,22 @@ package xyz.mcutils.backend.config; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.data.mongodb.MongoDatabaseFactory; +import org.springframework.data.mongodb.core.convert.DbRefResolver; +import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver; +import org.springframework.data.mongodb.core.convert.MappingMongoConverter; +import org.springframework.data.mongodb.core.mapping.MongoMappingContext; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; @Configuration @EnableMongoRepositories(basePackages = "xyz.mcutils.backend.repository.mongo") -public class MongoConfig { } +public class MongoConfig { + @Bean + public MappingMongoConverter mongoConverter(MongoDatabaseFactory databaseFactory, MongoMappingContext mongoMappingContext) { + DbRefResolver dbRefResolver = new DefaultDbRefResolver(databaseFactory); + MappingMongoConverter mongoConverter = new MappingMongoConverter(dbRefResolver, mongoMappingContext); + mongoConverter.setMapKeyDotReplacement("-DOT"); + return mongoConverter; + } +}