How do I avoid content fields in Joda objects?

2019-02-25 03:34发布

I'm using Joda objects (DateTime and DateTimeZone) in a document and whenever I access it via the REST interface I get entries with fields like this

lastAggregationDate: { content: "2016-07-12T17:58:43.643Z" }

instead of

lastAggregationDate: "2016-07-12T17:58:43.643Z"

I have the Joda Jackson dependencies declared and I see the de/serializers for these types so I'm puzzled as to what's at work here.

I've duplicated this behavior in a slightly modified Spring sample project but using Java's native date types rather than Joda's. I've added a date of birth property to the Person object and modified the shouldRetrieveEntity test to look for $.dateOfBirth.content. I've confirmed the serializer is being used and it seems like the LocalDate object is being treated as a resource rather than as a simple property.

2条回答
ら.Afraid
2楼-- · 2019-02-25 03:56

The issue results from Spring Boot not setting up MongoMappingContext correctly. A ticket has been created for Spring Boot and the fix is anticipated for the 1.4.1 release (credit for this answer goes to Oyku Gencay and Oliver Gierke). For more detail, see the ticket or the pull request.

查看更多
乱世女痞
3楼-- · 2019-02-25 04:12

This is fixed in Spring Data Hopper-SR4: https://jira.spring.io/browse/DATAMONGO-1498

查看更多
登录 后发表回答