When update a collection in hibernate parent class. Hibernate will generate the following SQL script. Here item records are set in a list of order record
Hibernate: update items set ORDERID=? where ID=? Hibernate: select hibernate_sequence.nextval from dual Hibernate: insert into items (name, ORDERID, ID) values (?, ?, ?) Hibernate: update items set ORDERID=null where ORDERID=? Hibernate: update items set ORDERID=? where ID=?
It un-references all records in order records by set the foreign key column to null.
Is it possible to delete the old records not mark their foreign key to null? Because these data are useless.
|