referencedColumnName
In JPA there is a an attribute called referencedColumnName that can be set on @JoinColumn, @PrimaryKeyJoinColumn what is the idea behind this setting, can some on give a good example of where this would be used?
"referencedColumnName" property is the name of the column in the table that you are making reference with the column you are anotating. Or in a short manner: it's the column referenced in the destination table. Imagine something like this: cars and persons. One person can have many cars but one car belongs only to one person (sorry, I don't like anyone else driving my car).
Table Person
name char(64) primary key
age int
Table Car
car_registration char(32) primary key
car_brand (char 64)
car_model (char64)
owner_name char(64) foreign key references Person(name)
When you implement classes you will have something like
class Person{
...
}
class Car{
...
@ManyToOne
@JoinColumn(columnName="owner_name", referencedColumnName="name")
private Person owner;
}
最新文章
- Switch语句的case穿透
- 如何理解泛型中的new()约束
- ASP.NET--GridView配合DetailsView初使用
- 三种方法实现js跨域访问
- 必应缤纷桌面的必应助手-软件分析和用户市场需求之-----二.体验部分 Ryan Mao (毛宇11061171) (完整版本请参考团队博客)
- C# where(泛型类型约束)
- android:layout_weight的真实含义
- SVN与TortoiseSVN实战:TortoiseSVN新建及合并分支
- 二分+叉积判断方向 poj 2318 2398
- 如何把powerpoint幻灯片大小改为标准或宽屏教程【图文】
- likely()与unlikely()
- [LeetCode] Valid Triangle Number 合法的三角形个数
- C# string 常用功能的方法扩展
- scipy 的K-means
- HDU5816 Hearthstone
- 自学Python之路-Python核心编程
- WxWidgets笔记
- Mina - 模拟同步请求
- 在静态方法和非静态方法上加 Synchronized的区别
- “服务器推”技术【转载+整理】