ColdFusion ORM - 未找到组件ARTISTS的映射。

时间:2014-02-13 17:16:59

标签: orm coldfusion

我正在研究ORM,并从我在adobe网站上找到的pdf开始学习一些教程。我在wwwroot下创建了一个名为test的文件夹。

这是我的application.cfc

component { 
   this.name = "artGalleryApp" ; 
   this.ormenabled = true ;
   this.datasource = "cfartgallery" ; 
} 

我在wwwroot / test / model文件夹下有artists.cfc。

<cfcomponent persistent="yes" table="artists" entityname="giggidy">
  <cfproperty name="id" column = "artistID" generator="increment">
      <cfproperty name="firstName">
      <cfproperty name="lastName">
      <cfproperty name="address">
      <cfproperty name="city">
      <cfproperty name="state">
      <cfproperty name="postalCode">
      <cfproperty name="email">
      <cfproperty name="phone">
      <cfproperty name="fax">
      <cfproperty name="thePassword">
  </cfcomponent>

然后,我有一个index.cfm,其中包含以下内容:

artists = EntityLoad("ARTISTS") ;
writeDump(artists) ; 

当我跑步时,我得到:

 Mapping for component ARTISTS not found.
 Either the mapping for this component is missing or the application must be restarted to generate the mapping.

我重启了CF应用服务器,这个错误就消失了。每次创建ORM应用程序时,是否必须重新启动CF应用服务器?

使用model.ARTISTS或其他方式指定此组件的位置是否更好?

现在,最大的问题。每当我需要DML语句时,我总是编写存储过程,包等(SQL Server,Oracle)。我从未在我的CF代码中包含内联查询。我还处理了这些过程,包等中的日志记录和错误处理。

如果我必须对数据库结构进行更改,我只需修改数据库端的内容。仅仅因为这个原因,使用ORM会带来什么好处?我更改了一个表添加/删除一个字段,我必须通过CF代码进行必要的更新。为什么呢?

1 个答案:

答案 0 :(得分:3)

Mapping for component ARTISTS not found因为:entityname="giggidy"

所以请使用EntityLoad("giggidy")

并使用ORMReload(),您无需重新启动CF。