org.mongodb.morphia.query.QueryException: sorting is not allowed for updates.
阿新 • • 發佈:2018-04-02
model ica -a inline operation per ati round 限制
代碼:
public UpdateResults updateProductByChannel(String channelId, String channelName){
Query<PixelProductModel> query = datastore.createQuery(PixelProductModel.class); query.order("-create"); query.field("channelId").equal(channelId); UpdateOperations<PixelProductModel> operations = datastore.createUpdateOperations(PixelProductModel.class); operations.set("channelName",channelName); return datastore.update(query,operations); }
異常: org.mongodb.morphia.query.QueryException: sorting is not allowed for updates.
原因: Mongo不支持對更新操作進行排序,補償或限制。 它確實支持對findAndModify操作進行排序,該操作也在 數據存儲
解決辦法: 去掉 query.order("-create");
org.mongodb.morphia.query.QueryException: sorting is not allowed for updates.