hibernate要关联的表一定要有主键,否则会自动生成一个。变成一个实体类和一个主键类。 用命令添加主键的语句是 :alter table userxx add constraint pk_userxx primary key(id);