on 2019 Jul 26 3:29 PM
Hi,I see that saveAll will pull all the models(both new and modified) from the current modelContext. So i'm wondering if modelContext is threadLocal object. Because if modelContext is not threadLocal.Then saveAll will save models in other places as well.
This will cause unexpected behavior. Like some models that shouldn't be saved will also be saved. Does anyone know how modelContext work in this case?
Request clarification before answering.
Hi ryan.zheng1988,
I know it's old post but answering so that it may be helpful to others. Ex: as follows.
ProductModel product1 = new ProductModel();
ProductModel product2 = new ProductModel();
ProductModel product3 = modelService.create(ProductModel.class);
ProductModel product4 = modelService.create(ProductModel.class);
Now, modelService.saveAll() will save only product3 and product4. because if you create models using factory method, i.e. modelService.create(...), they are associated to model context where if you create the products using new operator, you need to explicitly associate them to model context.
You can try this way so that modelService.saveAll() will not save your objects.
If you are trying to update existing models, you can use ModelService.lock(...).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.