|
26 | 26 | import java.util.Arrays;
|
27 | 27 | import java.util.List;
|
28 | 28 |
|
| 29 | +import javax.inject.Qualifier; |
| 30 | + |
| 31 | +import org.springframework.beans.factory.annotation.Value; |
29 | 32 | import org.springframework.core.DefaultParameterNameDiscoverer;
|
30 | 33 | import org.springframework.core.ParameterNameDiscoverer;
|
| 34 | +import org.springframework.core.annotation.AnnotationUtils; |
31 | 35 | import org.springframework.data.annotation.PersistenceConstructor;
|
32 | 36 | import org.springframework.data.mapping.PersistentEntity;
|
33 | 37 | import org.springframework.data.mapping.PersistentProperty;
|
|
46 | 50 | * @author Christoph Strobl
|
47 | 51 | * @author Roman Rodov
|
48 | 52 | * @author Mark Paluch
|
| 53 | + * @author Xeno Amess |
49 | 54 | */
|
50 | 55 | public interface PreferredConstructorDiscoverer<T, P extends PersistentProperty<P>> {
|
51 | 56 |
|
@@ -115,7 +120,7 @@ <T, P extends PersistentProperty<P>> PreferredConstructor<T, P> discover(TypeInf
|
115 | 120 | continue;
|
116 | 121 | }
|
117 | 122 |
|
118 |
| - if (candidate.isAnnotationPresent(PersistenceConstructor.class)) { |
| 123 | + if (AnnotationUtils.findAnnotation(candidate, PersistenceConstructor.class) != null) { |
119 | 124 | return buildPreferredConstructor(candidate, type, entity);
|
120 | 125 | }
|
121 | 126 |
|
@@ -153,7 +158,7 @@ <T, P extends PersistentProperty<P>> PreferredConstructor<T, P> discover(TypeInf
|
153 | 158 |
|
154 | 159 | return Arrays.stream(rawOwningType.getDeclaredConstructors()) //
|
155 | 160 | .filter(it -> !it.isSynthetic()) // Synthetic constructors should not be considered
|
156 |
| - .filter(it -> it.isAnnotationPresent(PersistenceConstructor.class)) // Explicitly defined constructor trumps |
| 161 | + .filter(it -> AnnotationUtils.findAnnotation(it, PersistenceConstructor.class) != null) // Explicitly defined constructor trumps |
157 | 162 | // all
|
158 | 163 | .map(it -> buildPreferredConstructor(it, type, entity)) //
|
159 | 164 | .findFirst() //
|
|
0 commit comments