November 2018
Intermediate to advanced
388 pages
9h 5m
English
It is also possible to back reference from the ContactDetails entity to the Person entity using the @ManyToOne annotation:
@Table(name = "contacts")@Entityclass ContactDetails { @Id private lateinit var id: Integer lateinit var number: String @Enumerated(EnumType.STRING) private var type: ContactType? = null @ManyToOne(cascade = arrayOf(CascadeType.ALL), fetch = FetchType.LAZY) lateinit var person: Person}
In the preceding code snippets, we have illustrated an example of the OneToMany and ManyToOne annotations. Similarly, we can use the OneToOne and ManyToMany annotations.
A relationship between two classes can be one of the following:
Read now
Unlock full access