From 0c38cfc9d7e8f4c49364f91d381817034269628a Mon Sep 17 00:00:00 2001 From: Emmanuel Bernard Date: Wed, 6 Jan 2016 15:02:38 +0100 Subject: [PATCH] HHH-10419 Detect if the user inappropriately left @Convert.converter to void --- .../hibernate/cfg/AbstractPropertyHolder.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AbstractPropertyHolder.java b/hibernate-core/src/main/java/org/hibernate/cfg/AbstractPropertyHolder.java index 515970dda1..9edadbf2e5 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AbstractPropertyHolder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AbstractPropertyHolder.java @@ -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) {