November 2018
Intermediate to advanced
388 pages
9h 5m
English
Since we bind a Contact entity to a Person, we can choose to give a name to the joining column. The name that we specify here will be the foreign key reference in the target entity, which is the contacts table:
@Table(name = "person")@Entityclass Person : Identity() { @Id lateinit var identifier: UUID lateinit var name: PersonName lateinit var loginId: String @Enumerated(EnumType.STRING) var preferredLanguage: PreferredLanguage? = null @OneToMany(cascade = arrayOf(CascadeType.ALL), fetch = FetchType.LAZY) @JoinColumn(name = "PERSON_ID") lateinit var contact: List<ContactDetails> lateinit var address: Address}
As the ContactDetails entity always refers to the Person entity with the PERSON_ID as foreign key, we can mark ...
Read now
Unlock full access