Reputation: 533
I've created a simple ColdFusion 9 ORM test as follows.
Application.cfc:
component {
this.ormenabled = "true";
this.datasource = "cfartgallery";
this.ormsettings.logSQL = "true";
}
State.cfc:
component persistent="true" {
property name="state_code" type="string" fieldtype="id";
property name="state_name" type="string" fieldtype="column";
}
index.cfm:
<cfscript>
ormreload();
</cfscript>
<cfdump var="#EntityLoad("State")#" />
Upon calling index.cfm I get the following error:
Error while loading the entity.
java.sql.SQLSyntaxErrorException: Table/View 'State' does not exist.
The error occurred in D:/WebDocs/tada/data/misc/basicorm/index.cfm: line 62
60 : </cfscript>
61 :
62 : <cfdump var="#EntityLoad("State")#" />
However, if I change index.cfm to use cfquery, shown below, a recordset is returned as expected without error.
<cfquery name="getstates" datasource="cfartgallery">
SELECT * FROM State
</cfquery>
I know that State.cfc is being processed because I can change the file to cause errors. Can anyone think of the problem? Thanks.
Upvotes: 2
Views: 647
Reputation: 773
You need to enable the dbcreate
setting for ORM config. Either set it to update
or dropcreate
. By default ORM will not create new or update tables based on persistent CFCs.
Upvotes: 4