This actually works for me using 0.107 code. I'm using a slightly modified converter which might have contributed to my success. The converter i'm using is below as well as the test.
@Entity
@Converters(MimeTypeConverter.class)
public static class MimeTyped {
@Id
private ObjectId id;
private String name;
private javax.activation.MimeType mimeType;
}
public class MimeTypeConverter extends TypeConverter {
public MimeTypeConverter() {
super(MimeType.class);
}
@Override
public Object decode(final Class targetClass, final Object fromDBObject, final MappedField optionalExtraInfo) {
try {
return new MimeType(((BasicDBObject) fromDBObject).getString("mimeType"));
} catch (MimeTypeParseException ex) {
return new MimeType();
}
}
@Override
public Object encode(final Object value, final MappedField optionalExtraInfo) {
return ((MimeType) value).getBaseType();
}
}
@Test
public void mimeType() throws UnknownHostException, MimeTypeParseException {
getMorphia().getMapper().getConverters().addConverter(new MimeTypeConverter());
MimeTyped entity = new MimeTyped();
entity.name = "test name";
entity.mimeType = new MimeType("text/plain"); //MimeTypeParseException
final DBObject dbObject = getMorphia().toDBObject(entity);
assertEquals("text/plain", dbObject.get("mimeType"));
getDs().save(entity);
}