I have an entity object which contains two element collections as such:
@Entity
public class Report {
// Electronic transactions items map
@ElementCollection(fetch = FetchType.EAGER)
@MapKeyColumn(name = "catElecItem_key", nullable = false)
@Cascade(value = { CascadeType.ALL })
public Map<Category, ReportItem> catElecItemMap;
// Branch transactions items map
@ElementCollection(fetch = FetchType.EAGER)
@MapKeyColumn(name = "catBranchItem_key", nullable = false)
@Cascade(value = { CascadeType.ALL })
public Map<Category, ReportItem> catBranchItemMap;
}
When the tables are being created, a table called Report_ReportItem is being generated to do the mapping between Category and the mapped ReportItem. However this fails as the when trying to save the maps, enther *catElecItem_key* or *catBranchItem_key* will be null.
If I try to annotate with nullable = true the table will fail to be created as both keys are used as part of the primary key definition.
Is it possible to specify for each collection to use a different table?
Have you tried using
@CollectionTableannotation?