Use criteria.all on subobjects created by spring-data-mongodb -
I have an object in which spring-data-mangaudb has an array of subbikes stored in mongo. Here is an example like my case:
{"_class": "com.foo.bar.Customer", "_id": ObjectId ("5050aef830041f24ff2bd16e"), "name": " "Discount": 0}<{productName: "test", "price": 9001}, {"productname": "test2", "price": 1337}] [>I I'm querying the update, let's say I want to update the discount for all customers with specific products in my cart. I'm querying this.
update update = new update () ; Update.set ("Discount", 10) List & lt; Products & gt; Products = New Arreelist & lt; Products.add (New Product ("Test", 9 001); Products (New Product ("Test 2", 1337); Write Result to Write Resis = Mongoops. Update Multi (Query ( ("Cart"). All (Products)), Update, Customer.Class);This does not work because every product used in spring $ all criteria is _class property , But Spring did not add _class to subbazyx but I had saved the customer first.
Or is there any way to do this work?
PS: I am using SpringData-MongloadB 1.5.0. According to the doctor, there should be a _ class attribute in suboback but they do not. Is this a known problem?
This is a bug in spring-data-mongodeb. The Spring subtype should add the +class attribute or when you do a subobacket query, you should leave it.
It is being fixed in the upcoming version of spring-data-mongodeb (1.7.0.m1). In this version, the query comparing subzjects does not associate the _class property for the JS that is sent to the MGO.
Comments
Post a Comment