DATACMNS-1082 - Skip synthetic constructors.

Constructor discovery no longer considers synthetic constructors for preferred constructor.

Original pull request: #225
This commit is contained in:
Roman Rodov
2017-06-07 11:40:13 +10:00
committed by Jens Schauder
parent 11c1ad8025
commit cabfa287cb
2 changed files with 35 additions and 0 deletions

View File

@@ -34,6 +34,7 @@ import org.springframework.data.util.TypeInformation;
*
* @author Oliver Gierke
* @author Christoph Strobl
* @author Roman Rodov
*/
public class PreferredConstructorDiscoverer<T, P extends PersistentProperty<P>> {
@@ -75,6 +76,11 @@ public class PreferredConstructorDiscoverer<T, P extends PersistentProperty<P>>
PreferredConstructor<T, P> preferredConstructor = buildPreferredConstructor(candidate, type, entity);
// Synthetic constructors should not be considered
if (preferredConstructor.getConstructor().isSynthetic()) {
continue;
}
// Explicitly defined constructor trumps all
if (preferredConstructor.isExplicitlyAnnotated()) {
this.constructor = Optional.of(preferredConstructor);