I\'ve just started working on a project using the play framework,jongo and MongoDB. The project was initially written in Play 2.1 with pojos with an String id field annotat
ObjectIdSerializer always writes property mapped with @ObjectId to a new instance of ObjectId. This is wrong when you map this property to a String.
To avoid this behaviour, I've write a NoObjectIdSerializer :
public class NoObjectIdSerializer extends JsonSerializer {
@Override
public void serialize(String value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeString(value);
}
}
used like this :
@ObjectId
@JsonSerialize(using = NoObjectIdSerializer.class)
protected final String _id;
There is an open issue.