Open spring-projects-issues opened 11 years ago
Is there any solution or alternative way to handle it?
I'm having the same difficulty. I'm trying some alternative using repositories customization.
@jh8nluiz if you find any alternative solution please help me.
James Cole opened DATAMONGO-754 and commented
We're using MongoRepository as much as possible to keep the number of custom queries throughout our code to a minimum (only using them in performance critical places).
I've recently been trying to share
@Document
entities between projects (DRY and all that), but noticed that if one project uses findOne() and then save() on an entity that was updated by the other project which had a new property, the save() wipes out any attributes for which it doesn't already have explicitly defined matching properties in the pojo entity.It'd be great if the framework could keep track of unknown attributes on an entity and then either ignore (maybe not easily possible with mongo) or at least re-persist the original values on save() instead of just wiping them.
The c-sharp mongo driver seems to have a good way to handle this by allowing you to put a placeholder [BsonExtraElements] annotation on a generic BsonDocument property to support non-obliteration of unknown properties: http://docs.mongodb.org/ecosystem/tutorial/serialize-documents-with-the-csharp-driver/#supporting-extra-elements It'd be great to see that in the spring data framework as well
2 votes, 3 watchers