Open GoogleCodeExporter opened 9 years ago
The converters aren't chosen by the order they were added but by rather by the
type they can convert. I created a BigDecimal converter which works fine.
public class BigDecimalConverter extends TypeConverter implements
SimpleValueConverter {
public BigDecimalConverter() {
super(BigDecimal.class);
}
@Override
public Object encode(Object value, MappedField optionalExtraInfo) {
return value.toString();
}
@Override
public Object decode(Class targetClass, Object fromDBObject, MappedField optionalExtraInfo) throws MappingException {
if (fromDBObject == null) return null;
return new BigDecimal(fromDBObject.toString());
}
}
Original comment by sebastia...@otto.de
on 8 Jul 2012 at 10:08
Sebastian, thanks!
Adding:
implements SimpleValueConverter
then Changing :
@Override
protected boolean isSupported(Class<?> c, MappedField optionalExtraInfo) {
return BigDecimal.class.isAssignableFrom(c);
}
to:
public BigDecimalConverter() {
super(BigDecimal.class);
}
Made it work!
Original comment by ceefour666@gmail.com
on 10 Sep 2012 at 10:33
Dear developer: Please mark this issue as "Invalid"
Original comment by ceefour666@gmail.com
on 10 Sep 2012 at 10:36
Original issue reported on code.google.com by
atang.su...@gmail.com
on 11 Jun 2012 at 10:56