见另一贴(100分)
http://community.csdn.net/Expert/topic/4454/4454095.xml?temp=.1961634

解决方案 »

  1.   

    <class name="Eduinfo" table="INNERDOC_LOG">
            <composite-id name="id" class="EmployeeEduKey">
                <key-many-to-one name="employee(的对象名)" column="empid" class="Employee"/>
                <key-many-to-one name="edu(对象名)" column="eduid" class="eduid所属的类(Edu)"/>
            </composite-id>
     
            <property name="username" column="eduname" type="java.lang.String" />
            <!-- 其他属性略-->
        </class>public Class EmployeeEduKey{
    private Employee employee;
    private Edu edu;
    ..
    }
    public Class Employee{
    private EmployeeEduKey id;
    ...
    }
      

  2.   

    错了上面的 public Class Employee{ //这里改成 Eduinfo
    private EmployeeEduKey id;
    ...
    }
      

  3.   

    Transaction tx = session.beginTransaction();    //开始一个事务
      tx.commit();                                    //提交事物
      tx.rollback();                                  //回滚事务其实,hibernate只是对jdbc做了轻量的封状,最终的实现,还是通过jdbc的事务管理来实现的,不过用户不必了解那么多,使用hibernate提供的接口就可以。
    至于,多主建,一般都是用主建类来实现。
    --------------------------------------------
    public class StudentCourse implements Serializable {
      private StudentCoursePK comp_id;
      private Float grade;
      ......
    --------------------------------------------
    package eqzhou.mis.studentCourse;import java.io.Serializable;
    import org.apache.commons.lang.builder.EqualsBuilder;
    import org.apache.commons.lang.builder.HashCodeBuilder;public class StudentCoursePK implements Serializable {
      private String studentId;
      private String courseId;
      public StudentCoursePK() {
      }
      public String getCourseId() {
        return courseId;
      }
      public String getStudentId() {
        return studentId;
      }
      public void setCourseId(String courseId) {
        this.courseId = courseId;
      }
      public void setStudentId(String studentId) {
        this.studentId = studentId;
      }  public boolean equals(Object other) {
          if ( !(other instanceof StudentCoursePK) ) return false;
          StudentCoursePK castOther = (StudentCoursePK) other;
          return new EqualsBuilder()
              .append(this.getStudentId(), castOther.getStudentId())
              .append(this.getCourseId(),castOther.getCourseId())
              .isEquals();
      }  public int hashCode() {
          return new HashCodeBuilder()
              .append(this.getStudentId())
              .append(this.getCourseId())
              .toHashCode();
      }}
    ---------------------------------------------<class
        name="eqzhou.mis.studentCourse.StudentCourse"
        table="student_course"
    >    <composite-id name="comp_id" class="eqzhou.mis.studentCourse.StudentCoursePK">
            <key-property
                name="studentId"
                column="STUDENT_ID"
                type="java.lang.String"
                length="8"
            >
            </key-property>
            <key-property
                name="courseId"
                column="COURSE_ID"
                type="java.lang.String"
                length="3"
            >
            </key-property>
        </composite-id>    ............
    ---------------------------------------------和你问题相关的部分内容,已经铁了出来,你看下。
      

  4.   

    java培训,java就业培训,软件培训,请到itfuture软件实战就业教育中心http://www.itfuture.org,它是it培训第一家敢以就业来验证培训质量的培训机构!
      

  5.   

    如果要对studentId做操作,双主键的调用方法是不是这样啊StudentCourse.getComp_id().getStudentId()
      

  6.   

    java培训,java就业培训,软件培训http://www.itfuture.org
    UP