我没有从传递引用的方法获取更新列表
List<Person> beans = new ArrayList<Person>();
boolean alreadyPresent = isPersonPresentOnSolr(solrServer, beans);
// beans.size() is zero
boolean isPersonPresentOnSolr(SolrServer solrServer, List<Person> beans)
{
QueryResponse response = solrServer.query(solrQry);
beans = response.getBeans(Person.class);
//beans.size() is 5
}
答案 0 :(得分:1)
你不应该做
beans = response.getBeans(Person.class); // you lost reference of object. it is c++ way,
//but not works for java
你应该做
List<Person> newBeans = response.getBeans(Person.class);
beans.addAll(newBeans);