程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> hibernate-Hibernate逆向工程不能生成引用關系

hibernate-Hibernate逆向工程不能生成引用關系

編輯:編程解疑
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;
    }

}


求大神幫忙解決


最佳回答:


http://www.2cto.com/database/201412/357867.html

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved