JPA:@PrimaryKeyJoinColumn(...)和@JoinColumn(...,insertable =?,updatable =?)相同? [英] JPA: is @PrimaryKeyJoinColumn(...) the same as @JoinColumn(..., insertable = ?, updatable = ?)?

查看:1341
本文介绍了JPA:@PrimaryKeyJoinColumn(...)和@JoinColumn(...,insertable =?,updatable =?)相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你可以从JPA规范中得出,如果 @PrimaryKeyJoinColumn(...),它没有可插入和可更新的参数,则与

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)

@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...

我与EclipseLink和Hibernate的映射异常相当不一致。 ..

I'm getting rather inconsistent mapping exception with EclipseLink and Hibernate...

这是 @PrimaryKeyJoinColumn JavaEE 5 + 6 Javadoc:

Here's the @PrimaryKeyJoinColumn JavaEE 5 + 6 Javadoc:

PrimaryKeyJoinColumn(JavaEE 5) < br>
PrimaryKeyJoinColumn(JavaEE 6)

引用:


...它可能用于OneToOne映射,其中引用实体的主键用作引用实体的外键。

... 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属性。

Note in JPA 2.0 you can also add an @Id to a @OneToOne mapping and avoid having the duplicate basic id attribute altogether.

参见

  • Identity and Sequencing > Primary Keys through OneToOne and ManyToOne Relationships and
  • OneToOne > Target Foreign Keys, Primary Key Join Columns, Cascade Primary Keys

来自 WikiBooks Java Persistence 页面

这篇关于JPA:@PrimaryKeyJoinColumn(...)和@JoinColumn(...,insertable =?,updatable =?)相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆