From 0cf875b3583762cfe06b0a9cc457191ececfe4fc Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Thu, 25 Apr 2013 15:13:42 +0200 Subject: [PATCH] DATACMNS-320 - Be less restrictive in finding mapping ambiguities. So far we threw exceptions in case we find the same exception on getters *and* setters. We now allow this scenario in case the annotations are semantically equivalent. --- .../model/AnnotationBasedPersistentProperty.java | 2 +- .../AbstractAnnotationBasedPropertyUnitTests.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java b/src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java index 32418b678..9d7fd25f0 100644 --- a/src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java +++ b/src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java @@ -82,7 +82,7 @@ public abstract class AnnotationBasedPersistentProperty

annotationType = annotation.annotationType(); - if (annotationCache.containsKey(annotationType)) { + if (annotationCache.containsKey(annotationType) && !annotationCache.get(annotationType).equals(annotation)) { throw new MappingException(String.format("Ambiguous mapping! Annotation %s configured " + "multiple times on accessor methods of property %s in class %s!", annotationType, getName(), getOwner() .getType().getName())); diff --git a/src/test/java/org/springframework/data/mapping/model/AbstractAnnotationBasedPropertyUnitTests.java b/src/test/java/org/springframework/data/mapping/model/AbstractAnnotationBasedPropertyUnitTests.java index 1d5627e91..c284f9fff 100644 --- a/src/test/java/org/springframework/data/mapping/model/AbstractAnnotationBasedPropertyUnitTests.java +++ b/src/test/java/org/springframework/data/mapping/model/AbstractAnnotationBasedPropertyUnitTests.java @@ -136,6 +136,7 @@ public class AbstractAnnotationBasedPropertyUnitTests