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

标签 coldfusion coldfusion-9

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

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

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

这是我的 CFC。任何关于我可能做错的事情的指示都表示赞赏。提前致谢!

出版物.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";
}

出版文章.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" ;
}

出版物类型.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" ;
}

最佳答案

你需要一个发电机。

property name="id" fieldtype="id" generator="identity";

关于coldfusion - ORM EntitySave() - 必须在调用 save() 之前手动分配此类的 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9797213/

相关文章:

JQUERY AJAX,发送到服务器的空格问题,为什么?

coldfusion - 将整个 CFM 页面包装在 cfoutput 标签中是否安全

datetime - 如何处理 CFML 中的时区?

javascript对象/数组未定义与空

pdf - 您可以使用 CF8 或 CF9 将 PDF 'package' 拆分为单独的文件吗?

html - 是否可以在 cfajaximport 生成的代码之前插入元标记 X-UA_兼容?

Java - GC 正在运行但不回收任何东西

Coldfusion 9 问题

logging - 当 ColdFusion 最大限度地使用 CPU 时,我如何找出它正在咀嚼/窒息的东西?

Coldfusion 9动态调用方法