MichaelJRussell opened a new issue, #14363:
URL: https://github.com/apache/grails-core/issues/14363

   I've reviewed the documentation at 
https://gorm.grails.org/latest/mongodb/manual/, I don't see how to take 
advantage of the codecs in `groovy.org.grails.datastore.bson.codecs`. My 
assumption was that just adding the MongoDb plugin to my application would 
automatically enable marshalling/unmarshalling of Java 8 types such as 
LocalDate and ZonedDateTime, but instead they're serialized as `String`, and 
when retrieved I receive an exception. Details follow.
   
   Steps I took:
   - Create a new Grails (v5.1.7) app: `grails create-app test-mongo --profile 
rest-api`
   - Add the Gorm MongoDb plugin to `build.config`: `implementation 
'org.grails.plugins:mongodb:7.3.0'`
   - Create a trivial Domain and associated Controller with `save` & `list` 
endpoints), with `LocalDate` and `ZonedDateTime` props
   - Add MongoDb connection settings to local dev config in `application.yml`
   
   `POST` to /foo successful, but serializes LocalDate and ZonedDateTime as 
`String`. On `GET`, receive the following error:
   
   >Failed to convert property value of type 'java.lang.String' to required 
type 'java.time.LocalDate' for property 'dob'; nested exception is 
java.lang.IllegalStateException: Cannot convert value of type 
'java.lang.String' to required type 'java.time.LocalDate' for property 'dob': 
no matching editors or conversion strategy found
   
   I also tried adding this: `implementation 
'org.grails:grails-datastore-gorm-mongodb:7.3.0'`, but same result.
   
   Example repo: https://github.com/MichaelJRussell/mongo-test
   - build.gradle: 
https://github.com/MichaelJRussell/mongo-test/blob/main/build.gradle
   - Domain: 
https://github.com/MichaelJRussell/mongo-test/blob/main/grails-app/domain/Foo.groovy


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to