打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Hibernate树型结构的算法,附源码!
/**
* @hibernate.class
*  table="tree"
*/

public class Component {
       
        private long id;

        private String name;
       
        private Component parent;
       
        private Set children=new HashSet();
       
        private Component(){}
       
        public Component(String name){
                this.name=name;
        }
       
        /**
        * @hibernate.id
        *  generator-class = "native"
        */
 
        public getId(){
                return Id;
        }
       
        private setId(long id){
                this.id=id;
        }
       
        /**
        * @hibernate.property
        *  length="64"
        *  not-null="true"
        */

        public String getName(){
                return name;
        }
       
        public void setName(String name){
                this.name=name;
        }
       
        /**
        * 获得父节点
        * @hibernate.many-to-one
        *  column="parentId"
        */

        public Component getParent(){
                return parent;
        }
       
        public void setParent(Component parent){
                this.parent=parent;
        }
       
        /**
        * 获得子节点
        * @hibernate.set
        *  lazy = "true"
        *  table = "tree"
        * @hibernate.collection-key
        *  column = "parentId"
        * @hibernate.collection-one-to-many
        *  class = "Component"
        */

        public Set getChildren(){
                return children;
        }
       
        private void setChildren(Set children){
                this.children=children;
        }
       
        public void addChild(Component child){
                children.add(child);
        }
       
        public void removeChild(Component child){
                childrent.remove(child);
        }
       
        public void clearChildren(){
                children=new HashSet();
        }
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Hibernate 组合映射使用
使用hibernate实现树形结构无限级分类
Eclipse快速上手Hibernate--5.组件映射
Hibernate Annotations 实战
HIBERNATE一对多配置实例
slave4j ,看了介绍,感觉不错。
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服