當前位置:編程學習大全網 - 網站源碼 - mysql查詢樹狀菜單有多少層

mysql查詢樹狀菜單有多少層

mysql查詢樹狀菜單有多少層

java版的實際例子。類同妳說的情況

private void findChildList(AssetType parent,List<AssetType> list){

String hql = "from AssetType a where a.parentAssetType.assetTypeId=? ORDER BY a.sort,a.assetTypeName asc";

List<AssetType> childList = this.assetTypeDao

.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<AssetType> childs = assetType.getChildAssetType();

if(childs.size()>0){

list.addAll(childs);

this.findChildList(assetType, list);//遞歸查詢節點的子節點

}

}

}

}

  • 上一篇:連雲港農村合作醫療網上繳費怎麽交
  • 下一篇:node.js文件放在nginx哪個目錄
  • copyright 2024編程學習大全網