您的位置:首页 > 其它

@Entity设置OneToMany

2015-09-17 19:45 344 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: