haoyuehong91 2016-11-14 11:49 采纳率: 0%
浏览 1282
已采纳

Hibernate逆向工程不能生成引用关系

各位大神,小弟自学java,今天学习逆向工程时,在生成的实体类中不能生成引用关系,,,
powerdesigner生成的物理模型如图:
图片说明

drop table if exists company;

/*==============================================================*/
/* Table: company /
/
==============================================================*/
create table company
(
comp_id varchar(32) not null,
comp_name varchar(80) not null,
comp_address varchar(100),
comp_desc text,
primary key (comp_id)
);

 drop table if exists department;

/*==============================================================*/
/* Table: department                                            */
/*==============================================================*/
create table department
(
   dept_id              varchar(32) not null,
   comp_id              varchar(32) not null,
   dept_name            varchar(20) not null,
   primary key (dept_id)
);

alter table department add constraint FK_company—department foreign key (comp_id)
      references company (comp_id) on delete restrict on update restrict;

/*==============================================================*/
/* Table: employee /
/
==============================================================*/
create table employee
(
emp_id varchar(32) not null,
dept_id varchar(32) not null,
emp_name varchar(20) not null,
primary key (emp_id)
);

alter table employee add constraint FK_department——employee foreign key (dept_id)
references department (dept_id) on delete restrict on update restrict;

hibernate逆向时没有生成set集合,也没有引用,更不存在关联关系
生成的实体类代码如下:
package entity;

/**
 * Employee entity. @author MyEclipse Persistence Tools
 */

public class Employee implements java.io.Serializable {

    // Fields

    private String empId;
    private String deptId;
    private String empName;

    // Constructors

    /** default constructor */
    public Employee() {
    }

    /** full constructor */
    public Employee(String deptId, String empName) {
        this.deptId = deptId;
        this.empName = empName;
    }

    // Property accessors

    public String getEmpId() {
        return this.empId;
    }

    public void setEmpId(String empId) {
        this.empId = empId;
    }

    public String getDeptId() {
        return this.deptId;
    }

    public void setDeptId(String deptId) {
        this.deptId = deptId;
    }

    public String getEmpName() {
        return this.empName;
    }

    public void setEmpName(String empName) {
        this.empName = empName;
    }

}

package entity;

/**
 * Department entity. @author MyEclipse Persistence Tools
 */

public class Department implements java.io.Serializable {




    // Fields

    private String deptId;
    private String compId;
    private String deptName;

    // Constructors

    /** default constructor */
    public Department() {
    }

    /** full constructor */
    public Department(String compId, String deptName) {
        this.compId = compId;
        this.deptName = deptName;
    }

    // Property accessors

    public String getDeptId() {
        return this.deptId;
    }

    public void setDeptId(String deptId) {
        this.deptId = deptId;
    }

    public String getCompId() {
        return this.compId;
    }

    public void setCompId(String compId) {
        this.compId = compId;
    }

    public String getDeptName() {
        return this.deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

}

package entity;

/**
 * Company entity. @author MyEclipse Persistence Tools
 */

public class Company implements java.io.Serializable {

    // Fields

    private String compId;
    private String compName;
    private String compAddress;
    private String compDesc;

    // Constructors

    /** default constructor */
    public Company() {
    }

    /** minimal constructor */
    public Company(String compName) {
        this.compName = compName;
    }

    /** full constructor */
    public Company(String compName, String compAddress, String compDesc) {
        this.compName = compName;
        this.compAddress = compAddress;
        this.compDesc = compDesc;
    }

    // Property accessors

    public String getCompId() {
        return this.compId;
    }

    public void setCompId(String compId) {
        this.compId = compId;
    }

    public String getCompName() {
        return this.compName;
    }

    public void setCompName(String compName) {
        this.compName = compName;
    }

    public String getCompAddress() {
        return this.compAddress;
    }

    public void setCompAddress(String compAddress) {
        this.compAddress = compAddress;
    }

    public String getCompDesc() {
        return this.compDesc;
    }

    public void setCompDesc(String compDesc) {
        this.compDesc = compDesc;
    }

}


求大神帮忙解决


  • 写回答

1条回答 默认 最新

  • dabocaiqq 2016-11-14 12:18
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元