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
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办