-
Apr 18th, 2012, 06:36 AM
#1
MongoDB saving derived fields
Just started using the spring data mongo API, finding it very nice so far.
The documentation states that when it comes to mapping "The fields of an object are used to convert to and from fields in the document. Public JavaBean properties are not used.". All well and good, but I want to be able to save properties that are derived from other data in the document into mongo so I can easily do queries on them. These derived properties aren't fields on the Java object in question - they are getters.
Is there a way I can accomplish this? Can I map the result of a getter to Mongo using the Spring data API? Or do I have to add a field for them?
I suppose a custom converter might do the trick, but that leads me to another question. Is there a way I can re-use the default converter behaviour, but just "extend" it after it has done its job? I don't want to have to manually specify the whole conversion for all fields in this Document, just the extra derived fields.
Many thanks,
Charles
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules