java版的实际例子。类同你说的情况
private void findChildList(AssetType parent,List
String hql = "from AssetType a where a.parentAssetType.assetTypeId=? ORDER BY a.sort,a.assetTypeName asc";
List
.getEntityManager()
.createQuery(hql)
.setParameter(1, parent.getAssetTypeId())
.getResultList();
int size = childList.size();
if(size>0){
for (int i = 0; i < size; i++) {
AssetType assetType = childList.get(i);
List
if(childs.size()>0){
list.addAll(childs);
this.findChildList(assetType, list);//递归查询节点的子节点
}
}
}
}