This content has been marked as final.
Show 1 reply
-
1. Re: Populating the relationship table
ruthlesset Jul 12, 2011 10:32 PM (in response to ruthlesset)So basically within the Employee class file (under the model directory) I have the below code:
@Transient
public void addAccount(int account_id)
{
if (!isAccountExists(account_id)) {
AccountEmployee ae = new AccountEmployee();
ae.setAccountId(account_id);
ae.setEmployeeId(this.id);
}
}
@Transient
private Boolean isAccountExists(int account_id)
{
Iterator<AccountEmployee> iter = this.getAccountEmployees().iterator();
while (iter.hasNext()) {
if (iter.next().getAccountId()==account_id) {
return true;
}
}
return false;
}
Although the new AccountEmployee is created, it is not save to the database. How do I make the Employee Entity actually update the AccountEmployee entities too?