JPA:@PrimaryKeyJoinColumn(...) 与@JoinColumn(..., insertable = ?, updateable = ?) 相同吗?
如果没有可插入和可更新参数的 @PrimaryKeyJoinColumn(...)
与
@JoinColumn(..., insertable = false, updatable = false)
或
@JoinColumn(..., insertable = true, updatable = true)
当用于常规(非继承)关联时?它们应该可以互换吗?可插入和可更新属性设置为什么?他们有什么设置吗?注意,我只针对两者(似乎)实现的只读属性...
我遇到了 EclipseLink 和 Hibernate 相当不一致的映射异常...
这是 @PrimaryKeyJoinColumn
JavaEE 5 + 6 Javadoc:
PrimaryKeyJoinColumn (JavaEE 5)
PrimaryKeyJoinColumn (JavaEE 6)
引用:
...并且它可以用在 OneToOne 映射中,其中引用实体的主键用作引用实体的外键。
Can you derive from the JPA spec, if @PrimaryKeyJoinColumn(...)
, which doesn't have the insertable and updatable parameters, is the same as
@JoinColumn(..., insertable = false, updatable = false)
or
@JoinColumn(..., insertable = true, updatable = true)
when used on regular (non-inheritance) associations? Should they be interchangable? What are the insertable and updatable properties set to? Are they set to anything at all? Note, I'm only targeting the read-only attribute that both (seem to) implement...
I'm getting rather inconsistent mapping exception with EclipseLink and Hibernate...
Here's the @PrimaryKeyJoinColumn
JavaEE 5 + 6 Javadoc:
PrimaryKeyJoinColumn (JavaEE 5)
PrimaryKeyJoinColumn (JavaEE 6)
Quote:
... 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,两者是等价的。
请注意,在 JPA 2.0 中,您还可以将
@Id
添加到@OneToOne
映射,并完全避免使用重复的基本 id 属性。请参阅
和
来自 WikiBooks Java Persistence 的 页面
Yes, the two are equivalent.
Note in JPA 2.0 you can also add an
@Id
to a@OneToOne
mapping and avoid having the duplicate basic id attribute altogether.See
and
from the WikiBooks Java Persistence pages