from t_dept t1 left join t_dept t2 on t1.sjid=t2.deptid
这样写比较靠谱。不能直接显示
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 = 0i <sizei++) {
AssetType assetType = childList.get(i)
List<AssetType>childs = assetType.getChildAssetType()
if(childs.size()>0){
list.addAll(childs)
this.findChildList(assetType, list)//递归查询节点的子节点
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)