建立cmp的时候会自动给你建立主键类的...

解决方案 »

  1.   

    package testbmp;import java.io.*;public class StudentPK
        implements Serializable {
      public String studentId;
      public String classId;  public StudentPK() {
      }  public StudentPK(String studentId, String classId) {
        this.studentId = studentId;
        this.classId = classId;
      }  public boolean equals(Object obj) {
        if (obj != null) {
          if (this.getClass().equals(obj.getClass())) {
            StudentPK that = (StudentPK) obj;
            return ( ( (this.studentId == null) && (that.studentId == null)) ||
                    (this.studentId != null && this.studentId.equals(that.studentId))) &&
                ( ( (this.classId == null) && (that.classId == null)) ||
                 (this.classId != null && this.classId.equals(that.classId)));
          }
        }
        return false;
      }  public int hashCode() {
        return (studentId + classId).hashCode();
      }
    }