2012-12-18 126 views
0

我这里有一些代码在ColdFusion中检索使用基本我的组织结构为环形折返它检索数据,并以树形结构

例如:

level1 = retrieveOrgs(1); 
for loop level1 
    <span>level1.description</span> 
    level2 = retrieveOrgs(level1.orgId); 
    for loop level2 
     <span>level2.description</span> 
     level3 = retrieveOrgs(level1.orgId); 
     for loop level3 
      .... 
     end; 
    end; 
end; 

我移动web应用程序,以使用spring/hibernate组合的java。我想知道在Java/Spring/Hibernate中是否有“更好”的方法。

感谢

回答

0

定义如下所示的实体,你就会有一个树状结构:

@Entity 
public class Org { 
    @OneToMany 
    private Set<Org> childrenOrgs; 
    ... 
}