HHH-10419 Detect if the user inappropriately left @Convert.converter to void

This commit is contained in:
Emmanuel Bernard 2016-01-06 15:02:38 +01:00
parent bb7cb7636b
commit 0c38cfc9d7
1 changed files with 18 additions and 4 deletions

View File

@ -94,10 +94,24 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
}
protected IllegalStateException buildExceptionFromInstantiationError(AttributeConversionInfo info, Exception e) {
return new IllegalStateException(
String.format( "Unable to instantiate AttributeConverter [%s]", info.getConverterClass().getName() ),
e
);
if ( void.class.equals( info.getConverterClass() ) ) {
// the user forgot to set @Convert.converter
// we already know it's not a @Convert.disableConversion
return new IllegalStateException(
"Unable to instantiate AttributeConverter: you left @Convert.converter to its default value void.",
e
);
}
else {
return new IllegalStateException(
String.format(
"Unable to instantiate AttributeConverter [%s]",
info.getConverterClass().getName()
),
e
);
}
}
protected AttributeConverterDescriptor makeAttributeConverterDescriptor(AttributeConversionInfo conversion) {