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;
}

最新文章

  1. Switch语句的case穿透
  2. 如何理解泛型中的new()约束
  3. ASP.NET--GridView配合DetailsView初使用
  4. 三种方法实现js跨域访问
  5. 必应缤纷桌面的必应助手-软件分析和用户市场需求之-----二.体验部分 Ryan Mao (毛宇11061171) (完整版本请参考团队博客)
  6. C# where(泛型类型约束)
  7. android:layout_weight的真实含义
  8. SVN与TortoiseSVN实战:TortoiseSVN新建及合并分支
  9. 二分+叉积判断方向 poj 2318 2398
  10. 如何把powerpoint幻灯片大小改为标准或宽屏教程【图文】
  11. likely()与unlikely()
  12. [LeetCode] Valid Triangle Number 合法的三角形个数
  13. C# string 常用功能的方法扩展
  14. scipy 的K-means
  15. HDU5816 Hearthstone
  16. 自学Python之路-Python核心编程
  17. WxWidgets笔记
  18. Mina - 模拟同步请求
  19. 在静态方法和非静态方法上加 Synchronized的区别
  20. “服务器推”技术【转载+整理】

热门文章

  1. SQLite 约束
  2. angular 格式化日期
  3. Docker 搭建 etcd 集群及管理
  4. C#中int32 的有效值范围
  5. mysql数据库主从搭建
  6. httpclient用法
  7. python3中str的函数
  8. 3.使用secureCRT连接PC,LINUX,开发板
  9. CodeForces 671A Recycling Bottles
  10. 浙大pat1050题解