Took me a while to work this one out but before I raise a bug I want to make certain I wasn’t miss understanding.
I’ve have a checkbox field which I’m binding to an jpa entity by way of FormGroup.
During the commit the system was throwing a ConversionException from ConverterUtil.c
} else if (modelType.isAssignableFrom(presentationValue.getClass())) {
// presentation type directly compatible with model type
return modelType.cast(presentationValue);
} else {
throw new Converter.ConversionException(
"Unable to convert value of type "
+ presentationValue.getClass().getName()
+ " to model type "
+ modelType
+ ". No converter is set and the types are not compatible.");
The issue is that method ‘isAssignableFrom’ is failing.
Eventually I worked out that the CheckBox value is a Boolean object whilst my Entity field was a boolean intrinsic.
Once I changed my entity to a Boolean the problem was resolved.
It does make me wonder why isAssignableFrom doesn’t handle conversions from intrinsic types to their counterpart Objects
e.g.
int - Integer
long - Long
boolean - Boolean
etc.
What also didn’t help is that somewhere along the way the error gets dumbed down to:
‘Could not convert value to boolean at …’
Whereas if the original exception had been displayed I would have discovered the issue much faster.
Brett