ORM one-to-many cascade="none"

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

David,

What would you expect it to do if cascade=“none” when the parent entity is
deleted?

Are you really saying that it sets the primary key on the child row to
null?

Maybe it would help if you show some detail of your configuration and state
clearly what happens when a parent object is deleted.

Aria Media Sagl
Via Rompada 40
6987 Caslano
Switzerland

+41 (0)91 600 9601
+41 (0)76 303 4477 cell
skype: ariamediaOn Tue, Jun 2, 2015 at 10:34 AM, David Sedeño <@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.
To post to this group, send email to 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.

This behaviour, even though odd feels right

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…

Mark Drew

develop • deploy • deliver
http://charliemikedelta.com ttp://charliemikedelta.com> On 2 Jun 2015, at 17:19, Nando Breiter <@Nando_Breiter> wrote:

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.

Unless you set the child’s parent_I’d to null you can’t delete the parent,
the constraint wouldn’t let you.

So the behaviour is correct, docs need sortingOn Tue, 2 Jun 2015 17:27 Mark Drew <@Mark_Drew> wrote:

This behaviour, even though odd feels right

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…

Mark Drew

develop • deploy • deliver
http://charliemikedelta.com

On 2 Jun 2015, at 17:19, Nando Breiter <@Nando_Breiter> wrote:

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> wrote:

Hi Nando,

2015-06-02 17:39 GMT+02:00 Nando Breiter <@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
+41 (0)76 303 4477 cell
skype: ariamedia

On Tue, Jun 2, 2015 at 10:34 AM, David Sedeño <@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.
To post to this group, send email to 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.


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.
To unsubscribe from this group and all its topics, send an email to
lucee+unsubscribe@googlegroups.com.
To post to this group, send email to 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.


David Sedeño Fernández
Zoconet SL
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.
To post to this group, send email to 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.


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.
To post to this group, send email to 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.


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.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/35E8C32E-6781-4594-B900-3840229D2A03%40gmail.com
https://groups.google.com/d/msgid/lucee/35E8C32E-6781-4594-B900-3840229D2A03%40gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

Hi Nando,

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,2015-06-02 17:39 GMT+02:00 Nando Breiter <@Nando_Breiter>:

David Sedeño

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 10:34 AM, David Sedeño <@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.
To post to this group, send email to 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.


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.
To unsubscribe from this group and all its topics, send an email to
lucee+unsubscribe@googlegroups.com.
To post to this group, send email to 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.


David Sedeño Fernández
Zoconet SL
david.sedeno@todocoleccion.net
Tel. 657 384 329

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: ariamediaOn Tue, Jun 2, 2015 at 5:52 PM, David Sedeño <@David_Sedeno> wrote:

Hi Nando,

2015-06-02 17:39 GMT+02:00 Nando Breiter <@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
+41 (0)76 303 4477 cell
skype: ariamedia

On Tue, Jun 2, 2015 at 10:34 AM, David Sedeño <@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.
To post to this group, send email to 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.


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.
To unsubscribe from this group and all its topics, send an email to
lucee+unsubscribe@googlegroups.com.
To post to this group, send email to 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.


David Sedeño Fernández
Zoconet SL
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.
To post to this group, send email to 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.

Try adding the inverse attribute to the child property in your parent entity:

property name=“child” cfc=“child” fieldtype=“one-to-many”
fkcolumn=“parent_id” cascade=“none” inverse=“true”;On 2 June 2015 at 16:52, David Sedeño <@David_Sedeno> wrote:

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.

Hi Julian,

cascade=“none” inverse=“true”;

that did what I want!

Thanks!—
David Sedeño

2015-06-03 9:51 GMT+02:00 Julian Halliwell <@Julian_Halliwell>:

Try adding the inverse attribute to the child property in your parent
entity:

property name=“child” cfc=“child” fieldtype=“one-to-many”
fkcolumn=“parent_id” cascade=“none” inverse=“true”;

On 2 June 2015 at 16:52, David Sedeño <@David_Sedeno> wrote:

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.


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.
To unsubscribe from this group and all its topics, send an email to
lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/CAC_5VorixnmG4vPKno%3DApqCgSuuxA%3DiyFLPuU4dfGjr_7inCSQ%40mail.gmail.com
.
For more options, visit https://groups.google.com/d/optout.


David Sedeño Fernández
Zoconet SL
david.sedeno@todocoleccion.net
Tel. 657 384 329