Hi all,
I have two tables "Securites" and "TradeList" . They are linked together creating a new table "SecurityTradeList" in a bi-directional association.
The problem is that the cascade delete works fine when I use MYSQL and works different when I use Apache Derby.
When I delete a record on the TradeList, MySQL deletes only the record I selected and the records on the table "SecurityTradeList".
Apache Derby deletes records on the tables "SecurityTradeList" and "Securites". That is wrong!
I created the following line in the file TradeList.hbm.xml
Code:
<!-- Bi-Directional Associations -->
<set cascade="delete-orphan" name="securities" table="SecurityTradeList">
<key column="codTradeList"/>
<many-to-many class="br.jaraujo.Security" column="codSecurity"/>
</set>
I created the following line in the file Security.hbm.xml
Code:
<!-- inverse="true" tells Hibernate that the class br.jaraujo.TradeList takes care of datebase updates. -->
<set cascade="delete-orphan" inverse="true" name="tradeList" table="SecurityTradeList">
<key column="codSecurity"/>
<many-to-many class="br.jaraujo.TradeList" column="codTradeList"/>
</set>
Well, I do know what can I do ! If you have any idea, please let me know !
Thanks !
Best regards,
Joao