Consider two Entity Employee and Address. Class Address { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column private String id; @Column (name = "name") private String name; //with corresponding getters and setters } Class VehicleOwner { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column private String id; @Column(name = "brandname" private String brandName; @Column (name = "ownerame") private String ownerName; //with corresponding getters and setters } To have a join between Employee name and CarOwner name, add @JoinColumn annotation as follow. @OneToOne @JoinColumn(name = "name", referencedColumnName = "ownername") private VehicleOwner vehicleOwner;
Join between Non-Primary Key of One Entiry and Non-Primary Key of other Entity
Posted by
Pratik Hada
Tuesday, October 6, 2015
~ 0 comments: ~
~ Post a Comment ~