可以从JPA规范派生,如果没有可插入和可更新参数的@PrimaryKeyJoinColumn(…)与
@JoinColumn(...,insertable = false,updatable = false)
要么
@JoinColumn(…,insertable = true,updatable = true)
用于常规(非继承)关联?应该互换吗?什么是可插入和可更新属性设置为?他们是否设定了任何东西?请注意,我只定位到(似乎)实现的只读属性…
我正在使用EclipseLink和Hibernate获得非常不一致的映射异常
这是@PrimaryKeyJoinColumn JavaEE 5 6 Javadoc:
PrimaryKeyJoinColumn (JavaEE 5)
PrimaryKeyJoinColumn (JavaEE 6)
引用:
… and it may be used in a OneToOne mapping in which the primary key of the referencing entity is used as a foreign key to the referenced entity.
解决方法
是的,两者是等效的.
请注意,在JPA 2.0中,您还可以将@Id添加到@OneToOne映射,并避免重复的基本id属性完全相同.
看到
> Identity and Sequencing > Primary Keys through OneToOne and ManyToOne Relationships
和
> OneToOne > Target Foreign Keys,Primary Key Join Columns,Cascade Primary Keys