用户登录
用户注册

分享至

hibernate 多表 标签

  • 作者: 别和我扯犊子啊
  • 来源: 51数据库
  • 2021-01-03
你要的是annotation的还是xml的呢,上面的那位朋友已经把annotation的写出来了,我给你写个xml的映射:这都可以在hibernate文档里找到的:




































然后他的表呢是三张:
create table Person ( personId bigint not null primary key )
create table PersonAddress ( personId bigint not null, addressId bigint not null, primary key (personId, addressId) )
create table Address ( addressId bigint not null primary key )



  key column是指在多的一端(student表)中添加一个名为gradeid的字段,添加的字段的值为当前配置文件中主键的值(即gradeid)。即实现了主外键关联

因为设置了inverse=true,实际上这个字段是在由student进行维护的···

顺便鄙视一下楼上打广告的····
软件
前端设计
程序设计
Java相关