hibernate annotation

    /**
     * 父级分类
     */ 
   @ManyToOne(cascade = CascadeType.PERSIST,  fetch = FetchType.LAZY)
   @JoinColumn(name="pid", referencedColumnName="id")
    public Groups getParent() {
        return parent;
    }

    public void setParent(Groups parent) {
        this.parent = parent;
    }
   
    /**
     * 子级分类
     */ 
   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY,mappedBy="parent")
   //@JoinColumn(name="pid", referencedColumnName="id") 
    public Set<Groups> getChildrens() {
        return childrens;
    }

    public void setChildrens(Set<Groups> childrens) {
        this.childrens = childrens;
    }

你可能感兴趣的:(annotation)