How can I implement two composition relations between two entities.
I have two entities, Inspection and InspectionDecision.
Inspection have 2 decisions, the agent decision and the manager decision.
A decision don’t exist alone so it’s a composition with Inspection.
I try this implementation but the reverse composition is not possible (Decision → Inspection) !
I have to select a mappedBy field but I have two fields…
@JmixEntity
@Table(name = "INSPECTION", indexes = [
Index(name = "IDX_INSPECTION_AGENT_DECISION", columnList = "AGENT_DECISION_ID"),
Index(name = "IDX_INSPECTION_MANAGER_DECISION", columnList = "MANAGER_DECISION_ID")
])
@Entity
open class Inspection {
@JmixGeneratedValue
@Column(name = "ID", nullable = false)
@Id
var id: UUID? = null
@JoinColumn(name = "AGENT_DECISION_ID")
@Composition
@OneToOne(fetch = FetchType.LAZY)
var agentDecision: InspectionDecision? = null
@JoinColumn(name = "MANAGER_DECISION_ID")
@Composition
@OneToOne(fetch = FetchType.LAZY)
var managerDecision: InspectionDecision? = null
…
}
@JmixEntity
@Table(name = "INSPECTION_DECISION")
@Entity
open class InspectionDecision {
@JmixGeneratedValue
@Column(name = "ID", nullable = false)
@Id
var id: UUID? = null
@Composition
@OneToOne(fetch = FetchType.LAZY, mappedBy = "???")
var inspection: Inspection? = null
…
}
Is there a solution to have a reverse composition with this implementation ?
Do I need to remove the 2 OneToOne and set a OneToMany ?