Reputation: 687
Is it possible to use @JoinColumn in hibernate without declaring a relationship? I need to know if I can map an Object without declaring a relationship. (I know it defeats the purpose of having an ORM but I'm curious if it's possible) Example:
@Entity
@Table(name="PERSON")
public Class Person {
@Id
private int id;
@JoinColumn(name="ADDRESS_ID")
private Address address //address is also an entity
}
Upvotes: 0
Views: 2025
Reputation:
@JoinColumn
annotation specifies a column for joining an entity association or element collection, it doesn't specify association type. Therefore, you should use it together with @ManyToOne
and other related annotations.
Upvotes: 1