ORM EntitySave()-此类的ID必须在调用save()之前手动分配

问题描述 投票:8回答:1

[尝试执行EntitySave("publications",arguments);时..我收到以下错误。

ids for this class must be manually assigned before calling save(): publications

我不知道为什么。我的数据库主键设置正确,并且我的CFC中的这些属性为setter = false。我在执行Google搜索时发现了一些关于此错误的信息,但似乎没有任何迹象表明是什么导致了我的问题。

这是我的CFC。任何关于我可能在做错事情的指示都值得赞赏。预先感谢堆!

Publications.cfc

component persistent="true" table="publications"  
hint="Publications"{
    property name="id" fieldtype="id" setter="false";
    property name="typeid" omrtype="int";
    property name="name" ormtype="string";
    property name="dateScheduled" ormtype="date" ;
    property name="tstamp" ormtype="date";

    property name="Article" fieldtype="one-to-many" cfc="publicationArticles" fkcolumn="publicationid";
}

publicationArticles.cfc

component persistent="true" table="publicationArticles"  
hint="Publications"{
    property name="id" fieldtype="id" setter="false"   ;
    property name="typeid" ormtype="int";
    property name="title" ormtype="string" ;
    property name="status" ormtype="boolean";

    property name="publication" fieldtype="many-to-one" cfc="publications" fkcolumn="publicationid" ;
}

publicationTypes.cfc

   component persistent="true" table="publicationTypes"    
hint="Publicatin Type - Lookup"{

    property name="id" fieldtype="id" setter="false"   ;
    property name="description" ormtype="string";

    property name="publications" fieldtype="one-to-many" cfc="publications" fkcolumn="typeid" ;
}
coldfusion coldfusion-9
1个回答
4
投票

您需要在属性上生成器。

property name="id" fieldtype="id" generator="identity";
© www.soinside.com 2019 - 2024. All rights reserved.