DATACMNS-840 - ReturnedClass now aborts parameter name detection for types with multiple constructors.

In case a DTO type exposes multiple no-argument constructors we now leniently abort the parameter name detection and let downstream users decide what to do in this particular case.

The problematic case can't be outright rejected here already as there's valid scenarios for that, e.g. in JPA the type could be used for multiple query methods, using explict constructor expressions listing arguments explicitly and thereby select one of the multiple constructors.
This commit is contained in:
Oliver Gierke
2016-04-08 10:09:37 +02:00
parent a842ed4e33
commit 5cfed9e003
2 changed files with 25 additions and 0 deletions

View File

@@ -283,6 +283,11 @@ public abstract class ReturnedType {
PreferredConstructorDiscoverer<?, ?> discoverer = new PreferredConstructorDiscoverer(type);
PreferredConstructor<?, ?> constructor = discoverer.getConstructor();
if (constructor == null) {
return Collections.emptyList();
}
List<String> properties = new ArrayList<String>();
for (PreferredConstructor.Parameter<Object, ?> parameter : constructor.getParameters()) {