mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#2199 - ScalarTypeWrapper doesn't handle "nullValue" correctly
Fix for - standard JPA AttributeConverter which doesn't have the getNullValue method, he/she can't convert null to a custom null object AttributeConverterAdapter probes the AttributeConverter for the nullValue rather than just assuming it is null.
This commit is contained in:
+11
-1
@@ -10,14 +10,24 @@ import javax.persistence.AttributeConverter;
|
||||
class AttributeConverterAdapter<B,S> implements ScalarTypeConverter<B, S> {
|
||||
|
||||
private final AttributeConverter<B,S> converter;
|
||||
private final B nullValue;
|
||||
|
||||
AttributeConverterAdapter(AttributeConverter<B, S> converter) {
|
||||
this.converter = converter;
|
||||
this.nullValue = probeNullValue();
|
||||
}
|
||||
|
||||
private B probeNullValue() {
|
||||
try {
|
||||
return converter.convertToEntityAttribute(null);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public B getNullValue() {
|
||||
return null;
|
||||
return nullValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user