2012-12-18 124 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; 
    ... 
}