From 39a7fb3adfcd0eb8db305e0d11bef2751f4c7a08 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Fri, 28 Mar 2014 15:39:34 +0200 Subject: [PATCH] INT-3346: Add `@Id` to `CMDbMS.MessageDocument` JIRA: https://jira.spring.io/browse/INT-3346 An `@Id` field is required when MongoDB auditing is enabled in the ApplicationContext. This change does not make the document Auditable, it just prevents an exception being thrown when auditing is enabled. --- .../store/ConfigurableMongoDbMessageStore.java | 11 ++++++++++- .../ConfigurableMongoDbMessageGroupStoreTests.java | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageStore.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageStore.java index fd88e4502a..e1fa8a5080 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageStore.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageStore.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.GenericConverter; import org.springframework.core.serializer.support.DeserializingConverter; import org.springframework.core.serializer.support.SerializingConverter; +import org.springframework.data.annotation.Id; import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.MongoDbFactory; import org.springframework.data.mongodb.core.IndexOperations; @@ -356,6 +357,14 @@ public class ConfigurableMongoDbMessageStore extends AbstractMessageGroupStore */ private static class MessageDocument { + /* + * Needed as a persistence property to suppress 'Cannot determine IsNewStrategy' MappingException + * when the application context is configured with auditing. The document is not + * currently Auditable. + */ + @Id + private String _id; + private final Message message; @SuppressWarnings("unused") diff --git a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageGroupStoreTests.java b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageGroupStoreTests.java index cf31dbaf23..6140b0d858 100644 --- a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageGroupStoreTests.java +++ b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageGroupStoreTests.java @@ -81,7 +81,7 @@ public class ConfigurableMongoDbMessageGroupStoreTests extends AbstractMongoDbMe TestGateway gateway = context.getBean(TestGateway.class); String result = gateway.service("foo"); assertEquals("FOO", result); - + context.close(); } public static interface TestGateway {