ColdFusion ORM:表/视图不存在

时间:2013-11-15 22:07:43

标签: object orm coldfusion coldfusion-9

我已经创建了一个简单的ColdFusion 9 ORM测试,如下所示。

的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")#" />

在调用index.cfm时,我收到以下错误:

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")#" />

但是,如果我将index.cfm更改为使用cfquery,如下所示,则会按预期返回记录集而不会出现错误。

<cfquery name="getstates" datasource="cfartgallery">
  SELECT * FROM State
</cfquery>

我知道正在处理State.cfc,因为我可以更改文件以导致错误。谁能想到这个问题?感谢。

1 个答案:

答案 0 :(得分:4)

您需要为ORM config启用dbcreate设置。将其设置为updatedropcreate。默认情况下,ORM不会基于持久性CFC创建新表或更新表。