另外,DDL如下create table job (
job_id int,
job_desc varchar(32),
primary key (job_id)
)create table emp (
emp_id int,
name varchar(32),
job_id int,
primary key (emp_id)
)alter table emp add index fk_job_id (job_id),
add constraint fk_job_id foreign key (job_id)
references job(job_id)

解决方案 »

  1.   

    各位xdjm帮帮我,我刚学hibernate,自己up一下
      

  2.   

    1.楼主的javabean根本就不合规范
    2.请加上<id
    name="Id"
    type="integer"
    column="job_id"
             unsaved-value="0"
    >
    3.既然是让虚拟机来生成主键,请去掉job1.setId(new Integer(1));emp1.setId(new Integer(1));这类的代码!
    4.Emp中jobid用来做什么?请去掉!
    5.<many-to-one
                name="job"
                class="lht.hibernate.Job"
                cascade="save-update"
                outer-join="auto"
                update="false"
                insert="false"
                access="property"
                column="job_id"
            />
    将insert="false"改为insert="true"
    ...
    好多问题,自己发现吧
      

  3.   

    谢谢楼上的,改成insert=true后,jvm丢出这个异常,要求你把true改成falsenet.sf.hibernate.MappingException: Repeated column in mapping for class lht.hibernate.Employee should be mapped with insert="false" update="false": manager_id