为什么我用hibernate来反响生成实体类,结果有三个文件呢?
  比如,我要将student表生成实体类,用的是hibernate,得到的为什么就是 student.java,studentId.java,student.hbm.xml这三个呢?
不是只有student.java 和student.hbm.xml这两个就可以了么?
student.java 
package com.demo.entity;/**
 * Student entity. @author MyEclipse Persistence Tools
 */public class Student implements java.io.Serializable { // Fields private StudentId id; // Constructors /** default constructor */
public Student() {
} /** full constructor */
public Student(StudentId id) {
this.id = id;
} // Property accessors public StudentId getId() {
return this.id;
} public void setId(StudentId id) {
this.id = id;
}}studentId.java
package com.demo.entity;import java.math.BigDecimal;/**
 * StudentId entity. @author MyEclipse Persistence Tools
 */public class StudentId implements java.io.Serializable { // Fields private String studentName;
private BigDecimal studentAge;
private BigDecimal id; // Constructors /** default constructor */
public StudentId() {
} /** full constructor */
public StudentId(String studentName, BigDecimal studentAge, BigDecimal id) {
this.studentName = studentName;
this.studentAge = studentAge;
this.id = id;
} // Property accessors public String getStudentName() {
return this.studentName;
} public void setStudentName(String studentName) {
this.studentName = studentName;
} public BigDecimal getStudentAge() {
return this.studentAge;
} public void setStudentAge(BigDecimal studentAge) {
this.studentAge = studentAge;
} public BigDecimal getId() {
return this.id;
} public void setId(BigDecimal id) {
this.id = id;
} public boolean equals(Object other) {
if ((this == other))
return true;
if ((other == null))
return false;
if (!(other instanceof StudentId))
return false;
StudentId castOther = (StudentId) other; return ((this.getStudentName() == castOther.getStudentName()) || (this
.getStudentName() != null
&& castOther.getStudentName() != null && this.getStudentName()
.equals(castOther.getStudentName())))
&& ((this.getStudentAge() == castOther.getStudentAge()) || (this
.getStudentAge() != null
&& castOther.getStudentAge() != null && this
.getStudentAge().equals(castOther.getStudentAge())))
&& ((this.getId() == castOther.getId()) || (this.getId() != null
&& castOther.getId() != null && this.getId().equals(
castOther.getId())));
} public int hashCode() {
int result = 17; result = 37
* result
+ (getStudentName() == null ? 0 : this.getStudentName()
.hashCode());
result = 37
* result
+ (getStudentAge() == null ? 0 : this.getStudentAge()
.hashCode());
result = 37 * result + (getId() == null ? 0 : this.getId().hashCode());
return result;
}}
student.hbm.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.demo.entity.Student" table="STUDENT" schema="SCOTT">
        <composite-id name="id" class="com.demo.entity.StudentId">
            <key-property name="studentName" type="string">
                <column name="STUDENT_NAME" length="20" />
            </key-property>
            <key-property name="studentAge" type="big_decimal">
                <column name="STUDENT_AGE" precision="22" scale="0" />
            </key-property>
            <key-property name="id" type="big_decimal">
                <column name="ID" precision="22" scale="0" />
            </key-property>
        </composite-id>
    </class>
</hibernate-mapping>有三个文件,运行程序就出错,我后来手动写,两个就对了。
student.java
package com.demo.entity;public class Student {
private String student_name;
private int student_age;
private int id; public String getStudent_name() {
return student_name;
} public void setStudent_name(String studentName) {
student_name = studentName;
} public int getStudent_age() {
return student_age;
} public void setStudent_age(int studentAge) {
student_age = studentAge;
} public int getId() {
return id;
} public void setId(int id) {
this.id = id;
}}student.hbm.xml<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" ><hibernate-mapping package="com.demo.entity">
<class name="Student" table="Student"> <id name="id" column="id">
<generator class="sequence"/>
</id>

<property name="Student_Name" column="Student_Name" not-null="true" length="20"/>
<property name="Student_Age" column="Student_Age" not-null="true"/> </class>
</hibernate-mapping>
为什么啊?各位大神,是自动生成的哪儿出错了么??急!