Rename ObjectId _id to id in jackson deserialization with Jongo and MongoDB

后端 未结 4 1146
夕颜
夕颜 2020-12-21 05:56

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

4条回答
  •  情书的邮戳
    2020-12-21 06:26

    The Jongo's behaviour has changed since 1.1 for a more consistent handling of its owns annotations.

    If your '_id' is a String and you want this field to be stored into Mongo as a String then only @Id is needed.

    @Id + @ObjectId on a String property means :

    "My String property named 'foo' is a valid ObjectId. This property has to be stored with the name '_id' and have to be handled as an ObjectId."

提交回复
热议问题