开发者社区> 问答> 正文

HIbernate中我没有指定id最后却有id生成

 @Entity
@DiscriminatorValue("员工")
public class Employ extends Person4 {
    private String title;
    private double salary;
    @ManyToOne(cascade=CascadeType.ALL,targetEntity=Manger.class)
    @JoinColumn(name="manger_id",nullable=true)
    private Manger manger;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }



    public Manger getManger() {
        return manger;
    }

    public void setManger(Manger manger) {
        this.manger = manger;
    }




}
 @Entity
@DiscriminatorValue("经理")
public class Manger extends Employ {


    private String department;
    @OneToMany(cascade=CascadeType.ALL
            , mappedBy="manger" , targetEntity=Employ.class)
    private Set<Employ> employs=new HashSet<Employ>();
    public String getDepartment() {
        return department;
    }
    public void setDepartment(String department) {
        this.department = department;
    }
    public Set<Employ> getEmploys() {
        return employs;
    }
    public void setEmploys(Set<Employ> employs) {
        this.employs = employs;
    }



展开
收起
云栖技术 2016-06-02 15:33:29 2026 0
0 条回答
写回答
取消 提交回答
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载