What would happen if you now create another Parent object, that now happens to have the same ID as the deleted object? All the children are now assigned to it. So maybe removing the parent_id IS the right behaviour so you don’t get really odd (and dangerous) behaviours…
Well, my interpretation is that the documentation is wrong, the behavior is understandable and seems correct to me, because it cleans up a reference that is no longer valid.
If you really want the reference to the parent to remain for some reason when the parent is deleted, then perhaps using a “soft delete” on the parent would solve the issue? By soft delete I mean add a field to the parent “isDeleted” and set that to true if the record is to be deleted (and don’t show isDeleted records to your users, of course).
Aria Media Sagl
Via Rompada 40
6987 Caslano
Switzerland
+41 (0)91 600 9601
+41 (0)76 303 4477 cell
skype: ariamedia
On Tue, Jun 2, 2015 at 5:52 PM, David Sedeño <@David_Sedeno mailto:David_Sedeno> wrote:
Hi Nando,
2015-06-02 17:39 GMT+02:00 Nando Breiter <@Nando_Breiter mailto:Nando_Breiter>:
David,
What would you expect it to do if cascade=“none” when the parent entity is deleted?
Well, in the “Building Applications with Coldfusion ORM” book it says:
“setting the cascade option to ’ none ’ and ColdFusion will not automatically update any other records in the database.”
So, I expect to hibernate not update the ‘child’ record at all.
Are you really saying that it sets the primary key on the child row to null?
No, in the Child table, the parent_id is set to null when the parent is deleted.
Maybe it would help if you show some detail of your configuration and state clearly what happens when a parent object is deleted.
Parent.cfc:
property name=“child” fieldtype=“one-to-many” fkcolumn=“parent_id” cascade=“none”;
If I delete a ‘parent’ object, I expect to childs rows stay with the parent_id as it was but hibernate set it to null.
Regards,
David Sedeño
Aria Media Sagl
Via Rompada 40
6987 Caslano
Switzerland
+41 (0)91 600 9601 tel:%2B41%20(0)91%20600%209601
+41 (0)76 303 4477 tel:%2B41%20(0)76%20303%204477 cell
skype: ariamedia
On Tue, Jun 2, 2015 at 10:34 AM, David Sedeño <@David_Sedeno mailto:David_Sedeno> wrote:
Hi,
I’m trying to use an one-to-many relation with the cascade=“none” option it won’t delete the childs objects, but it seems to not work, it puts the pk key to null in the child table.
It’s this option correctly supported or I’m missing something ?
Lucee Vers. 4.5.1.0
Thanks
David Sedeño
–
You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com mailto:lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com mailto:lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/d2389917-4ea0-4096-890c-d9c8fe9a18e6%40googlegroups.com https://groups.google.com/d/msgid/lucee/d2389917-4ea0-4096-890c-d9c8fe9a18e6%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.
–
You received this message because you are subscribed to a topic in the Google Groups “Lucee” group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lucee/8iOLar3Embs/unsubscribe https://groups.google.com/d/topic/lucee/8iOLar3Embs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lucee+unsubscribe@googlegroups.com mailto:lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com mailto:lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/CAGHrs%3D-pDBDRzVxqdApb69VbZQz0ZPmGyDuZOV%3DbnPyRGY6iyw%40mail.gmail.com https://groups.google.com/d/msgid/lucee/CAGHrs%3D-pDBDRzVxqdApb69VbZQz0ZPmGyDuZOV%3DbnPyRGY6iyw%40mail.gmail.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.
–
David Sedeño Fernández
Zoconet SL
david.sedeno@todocoleccion.net mailto:david.sedeno@todocoleccion.net
Tel. 657 384 329
–
You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com mailto:lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com mailto:lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/CAPJegvo0PqFFEaZ_XL6%3D0-ZO1_p7VMfKtgJnqRo4WWqf-ixnvQ%40mail.gmail.com https://groups.google.com/d/msgid/lucee/CAPJegvo0PqFFEaZ_XL6%3D0-ZO1_p7VMfKtgJnqRo4WWqf-ixnvQ%40mail.gmail.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.
–
You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com mailto:lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com mailto:lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/CAGHrs%3D_XoEWVeoFZGWxuhqvN7FADNDQbzXT44VzE9pUW-a_%3DXw%40mail.gmail.com https://groups.google.com/d/msgid/lucee/CAGHrs%3D_XoEWVeoFZGWxuhqvN7FADNDQbzXT44VzE9pUW-a_%3DXw%40mail.gmail.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.