Skip to content

Commit

Permalink
HHH-8068 Suggestion for improvement.
Browse files Browse the repository at this point in the history
  • Loading branch information
ammachado authored and brmeyer committed Aug 21, 2013
1 parent 9ee5392 commit d0a7a01
Showing 1 changed file with 17 additions and 3 deletions.
Expand Up @@ -39,6 +39,7 @@
import org.hibernate.transform.AliasToBeanConstructorResultTransformer;
import org.hibernate.transform.ResultTransformer;
import org.hibernate.transform.Transformers;
import org.hibernate.type.PrimitiveType;
import org.hibernate.type.Type;

/**
Expand Down Expand Up @@ -184,9 +185,22 @@ private Constructor resolveConstructor(String path) throws SemanticException {
catch ( PropertyNotFoundException e ) {
// this is the exception returned by ReflectHelper.getConstructor() if it cannot
// locate an appropriate constructor
throw new DetailedSemanticException( "Unable to locate appropriate constructor on class [" + className + "]", e );
}
}
String formattedMessage = formatMissingContructorExceptionMessage(className);
throw new DetailedSemanticException( formattedMessage, e );
}
}

private String formatMissingContructorExceptionMessage(String className) {
String[] params = new String[constructorArgumentTypes.length];
for ( int j = 0; j < constructorArgumentTypes.length; j++ ) {
params[j] = constructorArgumentTypes[j] instanceof PrimitiveType ?
( ( PrimitiveType ) constructorArgumentTypes[j] ).getPrimitiveClass().getName() :
constructorArgumentTypes[j].getReturnedClass().getName();
}
String formattedList = params.length == 0 ? "no arguments constructor" : StringHelper.join(", ", params);
return String.format( "Unable to locate appropriate constructor on class [%s]. Expected types are: %s",
className, formattedList );
}

public Constructor getConstructor() {
return constructor;
Expand Down

0 comments on commit d0a7a01

Please sign in to comment.