Closed semistone closed 3 years ago
We're missing the full code of MultiLocaleConverter
.
Anyway, it seems to me that this code is something I would not expect to work in the current release of HR, since JsonObject
isn't a built-in type.
OTOH, after #869, perhaps it works against current main
.
Wait, @DavideD, did #869 go out in the latest release?
Yes, #869 is in the latest release: 1.0.0.CR9
this is our MultiLocaleConverter
import ....
import io.vertx.core.json.JsonObject;
/**
* The attribute converter for the MultiLocaleValue
*/
@Converter
public class MultiLocaleConverter implements AttributeConverter<MultiLocaleValue<String>, JsonObject> {
private final TypeToken<MultiLocaleValue<String>> typeToken = new TypeToken<>(getClass()) {
};
private final Class<MultiLocaleValue<String>> typeClass = uncheckedCast(typeToken.getRawType());
@Override
public JsonObject convertToDatabaseColumn(MultiLocaleValue<String> name) {
if (name == null || MapUtils.isEmpty(name.getValues())) {
return null;
}
return JsonObject.mapFrom(name);
}
@Override
public MultiLocaleValue<String> convertToEntityAttribute(JsonObject dbData) {
if (dbData == null) {
return null;
}
MultiLocaleValue<String> multiLocaleValue;
try {
multiLocaleValue = dbData.mapTo(typeClass);
} catch (IllegalArgumentException ex) {
throw ValidationException.create(
INPUT_STREAM_READING_ERROR,
new DefaultErrorStatus<>(REST, UNPROCESSABLE_ENTITY.getCode(), null),
null);
}
return multiLocaleValue;
}
}
but it actually doesn't matter in this case, because that value is null in that testcase.
OK, I've fixed this bug in #942.
When merge entity into database
and Converter is
when insert
then it will throw exception
I just compare the CR6(OK) and CR9 (NG)
org.hibernate.reactive.adaptor.impl.PreparedStatementAdaptor
CR6
CR9
it will cause exception, because sqltype is object id