November 2018
Intermediate to advanced
388 pages
9h 5m
English
We can also specify the fetching strategies of the data using the fetch type attribute. For example, we can specify that we always want to fetch the ContactDetails eagerly when loading the Person entity. Consider the following code:
@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.EAGER) lateinit var contact: List<ContactDetails> lateinit var address: Address}
Since we have to execute a joint operation, we can also load the data lazily when the LAZY fetch type is specified:
@Table(name ...
Read now
Unlock full access