java递归查询数据库数据[通俗易懂]

大家好,又见面了,我是你们的朋友全栈君。
先查询第一层的 数据 ,然后调用递归循环第一层的数据,查询父Id等于第一层的Id,执行完成后第一层一下的所有数据就全部查询出来了。。。
public List<Information> getTreeList(Integer topId) {
String hql="from Information where isDelete=2 and id="+topId;
List<Information> entityList=baseDao.queryHQL(hql);
entityList.addAll(getSubList(entityList));
return entityList;
private List<Information> getSubList(List<Information> entityList) {
for (int i = 0; i < entityList.size(); i++) {
String hql="from Information where isDelete=2 and fatherId="+entityList.get(i).getId();
if(baseDao.queryHQL(hql).size()>0){
List<Information> list2=baseDao.queryHQL(hql);