介绍一下hibernate中实体类之间的关联和映射

2014-11-22 12:40:03 · 作者: · 浏览: 18

Many to one:
通过many-to-one元素,可以定义一种常见的与另一个持久化类的关联.这种关系模型是多对一关联:这个表的一个外键引用目标表的主键字段.
One to one
主键关联


Two tables related by a primary key association share the same primary key values. The primary key of one table is also a foreign key of the other.
唯一外键关联(单项双向)
单向:
双向:
1.在employee中加一个外键,

2.然后在person配置中加入
property-ref=“person的emplyee属性"/>
One to many:
unidirectional
Bidirectional
many to many:
many-to-many association has its own table, the link table or association table.
单向
双向