Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestore Data Mapping Does not work with Groovy Classes #939

Closed
jjathman opened this issue Feb 5, 2022 · 4 comments
Closed

Firestore Data Mapping Does not work with Groovy Classes #939

jjathman opened this issue Feb 5, 2022 · 4 comments
Assignees

Comments

@jjathman
Copy link

jjathman commented Feb 5, 2022

Describe the bug
It currently seems impossible to use a Groovy class as the object to save to Firestore due to the object mapping attempting to map some of the "hidden" fields that Groovy automatically adds to every class. I don't think there is any available configuration which allows for excluding these fields.

Sample

Data.groovy

@Document
class Data {
  @DocumentId
  String id
}

Attempting to save this document will generate this error:

reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Could not serialize object. Serializing Arrays is not supported, please use Lists instead (found in field 'metaClass.additionalMetaMethods')
Caused by: java.lang.IllegalArgumentException: Could not serialize object. Serializing Arrays is not supported, please use Lists instead (found in field 'metaClass.additionalMetaMethods')

I think there would be two relatively simple solutions that I would like to use. One would be to configure the mapper to always ignore certain classes MetaClass in this case, or allow the Exclude annotation to be applied to the class level and provide string properties to exclude. This would allow me to exclude the metaClass since I am unable to annotate it.

@elefeint
Copy link
Contributor

elefeint commented Feb 7, 2022

Spring Data already has handling for excluding such autogenerated fields, so this is likely a matter of finding where the Firestore implementation missed plugging into the property exclusion process.

@jjathman
Copy link
Author

jjathman commented Feb 7, 2022

That’s very interesting. Good find! Hopefully that means it’s not too much work to support it in the future.

@elefeint elefeint added the type: enhancement New feature or request label Feb 15, 2022
@elefeint
Copy link
Contributor

Leaving it open as a new feature.

@elefeint
Copy link
Contributor

elefeint commented Aug 9, 2022

We've looked into this some more, and the object-to-document functionality lives entirely in the client library. I will close this issue; please watch googleapis/java-firestore#996 for updates.

@elefeint elefeint closed this as completed Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants