文件格式使用hibernate-reverse-engineering更改POJO类

时间:2016-09-08 07:41:50

标签: java spring hibernate reverse-engineering

我是hibernate的新手。我正在使用hibernate-reverse-engineering来创建POJO。我已经完成了xml类配置。在第一次POJO类创建如下。

只有一个文件被创建为Student.java

Student.java

    @Entity
    @Table(name = "student", schema = "dbo", catalog = "classI")
    public class Student implements java.io.Serializable {
    private long studentid;
    private String stuname;
    private Date rank;
    @Id
    @Column(name = "studentid", unique = true, nullable = false)

    public long getstudentid() {
    return this.studentid;
   }
   .................getter setter methods for all fields..........

   }

我第二次运行Hibernate配置时,Student.java文件改变如下

@Entity
@Table(name = "student", schema = "dbo", catalog = "classI")
public class Student implements java.io.Serializable {
private studentID id;

public Student () {
 }

public Student(studentID id) {
    this.id = id;
}
@EmbeddedId
@AttributeOverrides({
        @AttributeOverride(name = "stuname", column = @Column(name = "stuname")),
        @AttributeOverride(name = "rank", column = @Column(name = "rank"))

        })
         public studentID getId() {
        return this.id;
        }

    public void setId(studentID id) {
     this.id = id;
     }
     }

studentID.java

 @Embeddable
 public class studentID implements java.io.Serializable {
 private long studentid;
    private String stuname;
    private String rank;
    public studentID () {
     }
   public studentID (String stuname, String rank) {
    this.stuname= stuname;
    this.rank= rank;
    }
    @Column(name = "stuname")
public String getstuname() {
    return this.stuname;
}

public void setstuname(String stuname) {
    this.stuname= stuname;
}

@Column(name = "rank")
public String getrank() {
    return this.rank;
}

public void setrank(String rank) {
    this.rank= rank;
}
}

为一个表创建了两个文件。我不知道这里发生了什么。我想知道为什么为一个表创建两个文件的原因。请指导我。

0 个答案:

没有答案