DATACMNS-763 - Fixed constructor in example of custom repository base class.

Added hint to which constructor of the superclass to override. Added test cas e to make sure the expected types are advertised in the case of an error.
This commit is contained in:
Oliver Gierke
2015-09-07 09:15:13 +02:00
parent 8992cc80a1
commit 360e473c3a
3 changed files with 48 additions and 5 deletions

View File

@@ -335,8 +335,16 @@ public abstract class RepositoryFactorySupport implements BeanClassLoaderAware {
Constructor<?> constructor = ReflectionUtils.findConstructor(baseClass, constructorArguments);
if (constructor == null) {
List<Class<?>> argumentTypes = new ArrayList<Class<?>>(constructorArguments.length);
for (Object argument : constructorArguments) {
argumentTypes.add(argument.getClass());
}
throw new IllegalStateException(String.format(
"No suitable constructor found on %s to match the given arguments: %s", baseClass, constructorArguments));
"No suitable constructor found on %s to match the given arguments: %s. Make sure you implement a constructor taking these",
baseClass, argumentTypes));
}
return (R) BeanUtils.instantiateClass(constructor, constructorArguments);