Hello to everybody,
i have a problem modelling a bidirectional oneToMany relation where the owning side deletes the owned objects. Here's the code:
owning side:
Code:
@OneToMany(fetch= FetchType.EAGER, cascade={CascadeType.ALL})
@JoinColumn(name = "sqlInputId")
@OrderBy("id")
public Set<DbSqlFieldMapping> getFieldMapping()
{
return fieldMapping;
}
and the owned side:
Code:
@ManyToOne
@JoinColumn(name="sqlInputId", insertable=false, updatable=false)
public DbSqlInput getSqlInput()
{
return sqlInput;
}
The foreign key is generated correctly and the owned entities are deleted, when I delete an input. But: when I do something like that:
Code:
input.setFieldMapping(null);
or
Code:
input.getFieldMapping().remove(m);
the owned entities are NOT deleted. Only the foreign keys are set null.
Question: What do I need to change, that the owned entities are deleted when remove from the set?
Thank you in advance
Mathias