spring-mongo-template中对内嵌集合对象 不定参数的查询

测试数据:

{
  "_id" : ObjectId("54c752ed5c01557fc2eba8f1"),
  "title" : "测试1,27",
  "products" : [{
      "name" : "石油",
      "classid" : "001",
      "status" : "1",
      "isorg" : "Y",
      "_class" : "jyd.info.article.model.Customization"
    }],
}

/* 2 */
{
  "_id" : ObjectId("54c755f34c2815a1467c5391"),
  "title" : "测试多产品",
  "products" : [{
      "name" : "nn油",
      "classid" : "001002",
      "status" : "1",
      "isorg" : "Y",
      "_class" : "jyd.info.article.model.Customization"
    }, {
      "name" : "xx油",
      "classid" : "001003",
      "status" : "1",
      "isorg" : "Y",
      "_class" : "jyd.info.article.model.Customization"
    }, {
      "name" : "ss油",
      "classid" : "001",
      "status" : "1",
      "isorg" : "Y",
      "_class" : "jyd.info.article.model.Customization"
    }]
}

/* 3 */
{
  "_id" : ObjectId("54c758664c28d74b28d8dc67"),
  "_class" : "jyd.info.article.model.Article",
  "title" : "test3",
  "products" : [{
      "name" : "eee",
      "classid" : "001005",
      "status" : "1",
      "isorg" : "Y",
      "_class" : "jyd.info.article.model.Customization"
    }]
}
需要的接口:

List

selectByParas(String[] products,String columnId);

接口实现:

	@Override
	public List
selectByParas(String[] products, String columnId) { Query query = new Query(); Criteria c = new Criteria(); Criteria[] c1 = new Criteria[products.length+1]; for(int i=0;i



你可能感兴趣的:(mongodb)