我有一个使用 JSF primefaces 和 EJB 托管 Bean 和休眠存储的项目。 http://www.primefaces.org/showcase/ui/treeAjax.jsf
问题:我不断收到内存不足或堆栈溢出错误,你能看出我的递归有问题吗?
@ManagedBean(name = "categoryController")
@RequestScoped
public class CategoryController implements Serializable {
...
@EJB
private CategoryFacade ejbFacade;
private TreeNode root;
public TreeNode getRoot() {
return root;
}
@PostConstruct
public void init() {
root = new DefaultTreeNode("Root", null);
System.out.print("Facade value=" + getFacade());
Category categoryRoot = getFacade().find(new Integer(1));
getSubcategories(categoryRoot, root);
}
private void getSubcategories(Category categoryRoot, TreeNode root) {
List<Category> list = getFacade().findByNamedQuery("Category.findByPCatid", "pcatid", categoryRoot);
Iterator<Category> it = list.iterator();
while (it.hasNext()) {
Category subcategory = it.next();
TreeNode nextNode = new DefaultTreeNode(subcategory.getUcatid(), root);
getSubcategories(subcategory, nextNode);
}
}
...
}