Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORM EntitySave() - ids for this class must be manually assigned before calling save()

When attempting to do an EntitySave("publications",arguments); .. I receive the following error.

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

I can't work out why.. My database primary keys are set up correctly, and I have setter=false these properties in my CFC. I have found a bit on this error doing a Google search, but nothing seems to indicate what is causing my issue here.

Here are my CFC's. Any pointers on what I might be doing wrong are appreciated. Thanks heaps in advance!

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" ;
}
like image 853
Jason Avatar asked Mar 21 '12 00:03

Jason


1 Answers

You need a generator on the property.

property name="id" fieldtype="id" generator="identity";
like image 153
Sean Walsh Avatar answered Oct 21 '22 01:10

Sean Walsh