@Entity设置OneToMany

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

上一篇:scrapy新浪天气


下一篇:struts2整合spring出现的Unable to instantiate Action异常