@Entity data class A_Log(val a: A, val price: Int)
And a method which persists them:
Copy code
@Transactional fun persist(val dto: PriceDto) {
val a: A = A(???)
val log: A_Log = (a, price = dto.price)
// persist methods
}
I think the problem is clear, any way to solve this egg-or-chicken problem except making fields nullable and using (
!!
) elsewhere in code?
j
Jaco
03/12/2021, 5:22 PM
The answer to your question is probably not in the structure of your classes but in the behaviour you need.
Do you really need to have a bi-directional relationship for storage?
u
123
03/12/2021, 6:06 PM
@Jaco seems like yes, because I need to have reference on parent from every log entity, and having last log reference on the main eitnty