I got an entity that has two mappings to the same table.
1. The first Mapping uses an Entity that maps all columns of the table. This entity is lazy loaded.
2. The second Mapping just maps a few columns of the table. This entity is eagerly and with read-only mode loaded.
When I am persisting the main entity the second Mapping is sometimes set to null, although there are values on the table.
What can I do, so that the second Mapping is filled correctly ?
Code:
@Entity
@Table(name = "Table1")
public class DocumentImpl extends AbstractTable {
@Exclude(Skip.EVERYTHING)
@JoinColumn(name = "DATA_ID", nullable = false)
@OneToOne(targetEntity = DataFull.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
private Data data= new DataFull();
@JoinColumn(name = "DATA_ID", nullable = true, insertable = false, updatable = false)
@OneToOne(targetEntity = DataMin.class, fetch = FetchType.EAGER)
private Data dataMin;
....