请允许我说,我有两个实体:Post
和Comment
(在冷战时期):
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 collection of Comments
. Now I d like to delete a Post
, and have the Comments
automatically deleted as well. I ve tried the straightforward method:
var post = EntityLoadByPK("Post", 13);
EntityDelete(post);
但是,我忘记了一种温和的错误,即:post_id
不能被定为无效。 我做了什么错误,我如何解决这个问题?