I thought that joinKeyColumnName()
handles @JoinColumn
, but in reality I could not get it to work. I want to get rid of the necessity to write name开发者_StackOverflow=""
in @JoinColumn
I want the property to be used as the column name.
You don't need to specify the @JoinColumn annotation at all:
@Entity
public class PrimaryEntity {
@OneToMany(mappedBy = "primaryEntity")
public List<RelatedEntity> getRelatedEntities() {
return relatedEntities;
}
}
@Entity
public class RelatedEntity {
@ManyToOne
public PrimaryEntity getPrimaryEntity() {
return primaryEntity;
}
}
精彩评论