0

使用 Transfer-ORM 映射到我的 Microsoft SQL 数据库时,我收到以下 Coldfusion 错误。我相信这是由映射我的链接表的配置错误的 transfer.xml 文件引起的。我不确定我是否完全理解复合 ID 的细微差别。你看到错误了吗?

错误:

找不到搜索的属性在对象“siteUsers.siteUsers”中找不到属性“siteID”

索引.cfm:

<cfset transfer = application.transferFactory.getTransfer()>
<cfset obj = transfer.new("users.users")>
<cfdump var="#obj#">

transfer.xml:(相关部分-我认为问题存在于siteUsers包中)

<package name="users">

  <object name="users" table="users" >
    <id name="userID" type="string" generate="true"/>
    <property name="username" type="string" column="username" nullable="false"/>
    <property name="friendlyName" type="string" column="friendlyName" nullable="true"/>
    <property name="email" type="string" column="email" nullable="true"/>
    <property name="isEnabled" type="boolean" column="isEnabled" nullable="false"/>

    <onetomany name="pages" lazy="true">
      <link to="pages.pages" column="lastModUserID"/>
        <collection type="array">
          <order property="pageID" order="asc"/>
        </collection>
    </onetomany>

    <onetomany name="siteUsers" lazy="true">
      <link to="siteUsers.siteUsers" column="userID"/>
      <collection type="array">
        <order property="siteID" order="asc"/>
      </collection>
    </onetomany>

    <onetomany name="textContent" lazy="true">
      <link to="textContent.textContent" column="authorID"/>
      <collection type="array">
        <order property="textContentID" order="asc"/>
      </collection>
    </onetomany>

    <onetomany name="textContent" lazy="true">
      <link to="textContent.textContent" column="approvalUserID"/>
      <collection type="array">
        <order property="textContentID" order="asc"/>
      </collection>
    </onetomany>
  </object>

</package>

<package name="siteUsers">

  <object name="siteUsers" table="siteUsers" >
    <compositeid>
      <manytoone name="siteID" />
      <manytoone name="userID" />
    </compositeid>
    <property name="accessLevel" type="string" column="accessLevel" nullable="false"/>

    <manytoone name="siteID">
      <link to="sites.sites" column="siteID"/>
    </manytoone>

    <manytoone name="userID">
      <link to="users.users" column="userID"/>
    </manytoone>
  </object>

</package>

<package name="sites">
  <object name="sites" table="sites" >
    <id name="siteID" type="string" generate="true"/>
    <property name="themeID" type="string" column="themeID" nullable="true"/>
    <property name="sitename" type="string" column="sitename" nullable="false"/>
    <property name="menuName" type="string" column="menuName" nullable="true"/>
    <property name="menuID" type="string" column="menuID" nullable="true"/>
    <property name="description" type="string" column="description" nullable="true"/>
    <property name="basepath" type="string" column="basepath" nullable="true"/>
    <property name="reqApproval" type="boolean" column="reqApproval" nullable="false"/>
    <property name="enabled" type="boolean" column="enabled" nullable="false"/>
    <property name="redirectPath" type="string" column="redirectPath" nullable="true"/>

    <onetomany name="fileFolders" lazy="true">
      <link to="fileFolders.fileFolders" column="siteID"/>
      <collection type="array">
        <order property="fileFolderID" order="asc"/>
      </collection>
    </onetomany>

    <onetomany name="pages" lazy="true">
      <link to="pages.pages" column="siteID"/>
      <collection type="array">
        <order property="pageID" order="asc"/>
      </collection>
    </onetomany>

    <onetomany name="siteHandlers" lazy="true">
      <link to="siteHandlers.siteHandlers" column="siteID"/>
      <collection type="array">
        <order property="siteID" order="asc"/>
      </collection>
    </onetomany>

    <onetomany name="siteOptions" lazy="true">
      <link to="siteOptions.siteOptions" column="siteID"/>
      <collection type="array">
        <order property="siteOptionID" order="asc"/>
      </collection>
    </onetomany>

    <onetomany name="siteUsers" lazy="true">
      <link to="siteUsers.siteUsers" column="siteID"/>
      <collection type="array">
        <order property="siteID" order="asc"/>
      </collection>
    </onetomany>
  </object>

</package>
4

2 回答 2

0

要正确配置 Transfer-ORM,需要对配置文件进行三项验证:

  1. 它是正确形成的 XML 吗?

  2. 它是否符合 transfer.xsd 架构文件?

  3. transfer.xml 中的关系是否与数据库中的关系匹配?

我在#1 和#2 上通过了验证,但在#3 中使用了错误的关系标签。

更多信息:

于 2010-01-22T16:18:51.710 回答
0

可能的原因是您为相同的关系定义了 o2m 和 m2o。我记得,这是不允许的。

于 2010-01-21T23:07:57.683 回答