首页 > Web开发 > 详细

@Entity设置OneToMany

时间:2015-09-17 21:26:47      阅读:176      评论:0      收藏:0      [点我收藏+]

Hibernate设置bean映射数据库的方式有配置模式与注解模式,下面通过注解模式配置OneToMany

@Entity
@Table(name="csdnbbs_sys_catalog")
@org.hibernate.annotations.Proxy(lazy = false)
public class Catalog {

private Catalog parent ;
        
private String  id ;
private String  name ;
private String  url ;


private Set<Catalog> children = new HashSet<Catalog>();


@OneToMany(cascade=CascadeType.ALL, mappedBy="parent")
        public Set<Catalog> getChildren() {
return children;
}
public void setChildren(Set<Catalog> children) {
this.children = children;
}

}

鸣谢:http://bbs.csdn.net/topics/390522138

 

@Entity设置OneToMany

原文:http://www.cnblogs.com/wql025/p/4817494.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!