@Entity设置OneToMany

时间:2023-03-09 02:05:27
@Entity设置OneToMany

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

@Entity
@Table(name="****bbs_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.****.net/topics/390522138