hibernate关联映射

----------------------------------------------------Bug--------------------------------------------------------------------
HashCode

 

员工表中包含多个项目,因此创建一个项目集合并初始化,但是在使用这个项目集合的时候还是会报空指针异常,
是因为hashCode()方法出错,之前我生成Project类的时候,他的主键的属性是int/long类型的,我把它改成了Long类型,却没有重新生成hashCode方法,因此会报错。
hibernate里联合主键composite-id映射
create table PROEMP
(
  RPROID NUMBER(6) not null,
  REMPID NUMBER(6) not null
);
-- Create/Recreate primary, unique and foreign key constraints 
alter table PROEMP
  add constraint PK_PROEMP primary key (RPROID, REMPID);--创建联合主键
alter table PROEMP
  add constraint FK_EMPID foreign key (REMPID)  references EMPLOYEE (EMPID);
alter table PROEMP
  add constraint FK_PROID foreign key (RPROID)  references PROJECT (PROID);

在hibernate自动生成entity和映射文件的时候

也会生成这个类,但是不会生成这个类的映射文件。
 

 

 

posted @ 2019-07-11 14:50  TangXinPing  阅读(98)  评论(0编辑  收藏  举报