Join between Non-Primary Key of One Entiry and Non-Primary Key of other Entity

0 comments
Join between Non-Primary Key of One Entiry and Non-Primary Key of other Entity




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;


Team Building Chitwan 2011

0 comments
Team Building Chitwan 2011





splash at Rosy !

A new Beginning

2 comments
A new Beginning

HI ALL

Followers

Pageviews past week

Theme images by sndr. Powered by Blogger.

Search This Blog