MondoDB Query failed with error code 2 and error message 'Projection cannot have a mix of inclusion
2018-01-12 00:00
776 查看
Java操作MongoDB限定返回字段的时候报错:MondoDB Query failed with error code 2 and error message 'Projection cannot have a mix of inclusion and exclusion.
以下是我的代码:
BasicDBObject fields = new BasicDBObject()
.append("_id", 0)
// .append("itemName", 1)
.append("usl", 0)
.append("lsl",0)
.append("unit",0)
.append("data", 0);
collection.find().projection(fields).forEach(printBlock);
原因:Projection 不允许 inclusion and exclusion混合使用,注释掉那一块就好了
以下是我的代码:
BasicDBObject fields = new BasicDBObject()
.append("_id", 0)
// .append("itemName", 1)
.append("usl", 0)
.append("lsl",0)
.append("unit",0)
.append("data", 0);
collection.find().projection(fields).forEach(printBlock);
原因:Projection 不允许 inclusion and exclusion混合使用,注释掉那一块就好了
相关文章推荐
- Query failed with error code 96 and error message 'Executor error during find command: OperationFail
- mongodb 报错:Query failed with error code 13 and error message 'not authorized for query on ..."
- Translating SQLException with SQL state '42000', error code '1064', message [You have an error in yo
- OCIEnvNlsCreate failed with return code -1 but error message text was not available.
- Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details
- Oracle Error - "OCIEnvCreate failed with return code -1 but error message text was not available".
- Installation failed with message...It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
- Caused by: java.lang.OutOfMemoryError: Failed to allocate a 29433932 byte allocation with 14683576 free bytes and 14MB
- java.lang.OutOfMemoryError: Failed to allocate a 3110419 byte allocation with 741152 free bytes and
- An error occurred during the execution of xp_cmdshell. A call to 'LogonUserW' failed with error code: '1385'
- BEA-141150 - An error occurred while preparing application component uri of application application with HTTP response responseCode: message
- SqlException with message "Caught java.io.CharConversionException." and ERRORCODE=-4220
- Error creating bean with name 'assetQueryController': Injection of autowired dependencies failed; ne
- Error creating bean with name 'userServiceImpl': Injection of autowired dependencies failed
- MS SQL错误:SQL Server failed with error code 0xc0000000 to spawn a thread to process a new login or connection. Check the SQL Server error log and the Windows event logs for information about possible related problems
- com.mongodb.MongoQueryException: Query failed with error code 13
- WinRM不起作用 Connecting to remote server failed with the following error message : WinRM cannot complete the operation
- Compiler Error Message: The compiler failed with error code 128. 的问题解决
- SqlException with message "Caught java.io.CharConversionException." and ERRORCODE=-4220
- Debug error:"One or more breakpoints cannot be set and have been disabled.Execution will stop at the beginning of the program."