I've been caught in a bind for last two days. Please help...
From the code below 'SchemaExport' generates the table, "AccountRecords_Record", and three fields, "AccountRecords_id", "creditRecordList_hbm_id", and "debitRecordList_hbm_id" on that table.
This is fine... but...
Whenever I tried to make an 'AccountRecords' object persistent, I get an error message, "NULL value was tried to be inserted to the column, 'debitRecordList_hbm_id' on the table, 'AccountRecords_Record'.
Code:
@Entity
public class AccountRecords {
private Long id;
private List<Record> creditRecordList = new ArrayList<Record>();
private List<Record> debitRecordList = new ArrayList<Record>();
@OneToMany(cascade = CascadeType.ALL, targetEntity=Record.class)
public List<Record> getCreaditRecordList() {
return creditRecordList;
}
@OneToMany(cascade = CascadeType.ALL, targetEntity=Record.class)
public List<Record> getDebitRecordList() {
return debitRecordList;
}
// .....
}
It seems this is caused by having two "OneToMany" relationships i.e. creditRecordList_hbm_id and debitRecordList_hbm_id on the same table. Which annotation allows me to separate them? Or, is there any other solution to this problem?