JPA:@ManyToOne 关系的默认列名映射
当我们有一个类:
@Entity
Order implements Serializable {
@Id
private Integer id;
...
}
并且:
@Entity
OrderLine implements Serializable {
@Id
private Integer id;
@ManyToOne
Order order;
...
}
属性order将映射到什么行名称?
order_id、ORDER_ID 还是 Order_id?
(故意省略 @JoinColumn(name='order_id'))
When we have a class:
@Entity
Order implements Serializable {
@Id
private Integer id;
...
}
and:
@Entity
OrderLine implements Serializable {
@Id
private Integer id;
@ManyToOne
Order order;
...
}
What row name will the property order map to?
order_id, ORDER_ID or Order_id?
(ommiting the @JoinColumn(name='order_id') is deliberate)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可能不明白你的问题。但是,您不需要像下面这样的东西吗?
这里有一些示例
I might not understand your question. However, don't you need something like below?
here are some examples
以下是 JPA 1.0 规范中有关
JoinColumn
注释的内容:因此,在您的示例中,外键列的默认名称为
order_id
。参考
Here is what the JPA 1.0 specification writes about the
JoinColumn
annotation:So in your example, the default name of the foreign key column would be
order_id
.References