Announcement Announcement Module
Collapse
No announcement yet.
I have a problem related to "$or" Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • I have a problem related to "$or"

    I'm sorry, my English is very poor, there is no way to detailed queries based on keywords "$or".

    I find a problem in company project.

    I created a query:
    {
    '$or':[{'auditStatus':{'$ne':'1'}},{'auditStatus':{ '$exists' : false}}],
    '$or':[{'accountStatus':'0'},{'accountStatus':{ '$exists' : false}}],
    'contractAccount':{'$exists':false},
    'isDel':{'$ne':'1'}
    }

    It work in console, as shown
    Attachment

    But when I use @Query in repository,
    Code:
    	@Query(
    		value = ""
    			+ "{"
    			+ "$or:[{'accountStatus':'" + HrManagersBo.ACCOUNT_STATUS_NORMAL + "'},{'accountStatus':{$exists:false}}],"
    			+ "$or:[{'auditStatus':{$ne:'1'}},{'auditStatus':{$exists:false}}],"
    			+ "'contractAccount':{$exists:false},"
    			+ "'isDel':{$ne:'" + ApplicationConfig.HAS_BEEN_DELETED + "'}"
    			+ "}", 
    		fields = "{'id':1}"
    	)
    	public List<HrManagersBo> findImportedCompanyID();
    Parallel relationship "$or", only retains one.
    2012-06-27 11:38:36 MongoTemplate [DEBUG] find using query: { "$or" : [ { "accountStatus" : "0"} , { "accountStatus" : { "$exists" : false}}] , "contractAccount" : { "$exists" : false} , "isDel" : { "$ne" : "1"}} fields: null for class: class com.myjob.src.company.domain.HrManagersBo in collection: hrManagersBo


    How should I handle this situation? (By the way: Is the same at BasicQuery)
    Attached Files
Working...
X