Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I avoid content fields in Joda objects?

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.

like image 823
roborative Avatar asked Jun 23 '26 16:06

roborative


2 Answers

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

like image 198
Sergey Shcherbakov Avatar answered Jun 26 '26 05:06

Sergey Shcherbakov


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.

like image 41
roborative Avatar answered Jun 26 '26 06:06

roborative



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!