Let's say I have two objects: Post and Comment (in ColdFusion):
component persistent="true" table="post" { property name="Id" fieldtype="id"; property name="Comments" fieldtype="one-to-many" cfc="Comment" fkcolumn="post_id" cascade="all"; } component persistent="true" table="comment" { property name="Id" fieldtype="id"; property name="Post" fieldtype="many-to-one" cfc="Post" column="post_id"; }
Post has a set of Comments . Now I would like to delete Post and automatically delete Comments . I tried a simple method:
var post = EntityLoadByPK("Post", 13); EntityDelete(post);
But I get a Hibernate error stating that post_id cannot be set to null. What am I doing wrong and how can I fix this problem?
source share