On a simple one-to-many mapping:
Code:
<class name="entities.Instrument" table="DAT_INSTRUMENT">
...
<bag name="prices" table="DAT_PRICE" cascade="all" inverse="true" lazy="true" >
<key column="FK_INSTRUMENT"/>
<one-to-many class="entities.Price"/>
</bag>
</class>
on a simple class:
Code:
public class Instrument implements Serializable {
...
private List prices = new LinkedList();
...
public void setPrices(List prices) {
this.prices = prices;
}
public List getPrices() {
return prices;
}
}
when I try this code:
Code:
Iterator it = session.iterate("from Instrument inst where inst.code = 'I-1107280'");
while (it.hasNext()) {
Instrument instrument = (Instrument) it.next();
instrument.getPrices().clear();
session.saveOrUpdate(instrument);
}
I expect that all Prices entities attached to selected Instruments should be deleted without being initialized.
I bet I've done something wrong somewhere since the Prices list get initialized but nothing in it is deleted.
Any hint ? Thanks.