让 ORM 在 ColdFusion 9 中工作

发布于 2024-12-21 09:34:03 字数 1092 浏览 3 评论 0原文

我正在针对 Oracle 11g 数据库运行的 ColdFusion 应用程序中设置 ORM(在 application.cfc 中使用 Oracle10g 方言),但关系未加载。这是我设置的映射。这是一个带有外键到 tag_category 表中的标记表:

<cfcomponent output="false" persistent="true" entityname="tag" table="tag">
    <cfproperty fieldtype="id" name="id" column="tag_id">
    <cfproperty fieldtype="column" name="tag_name" column="tag_name">
    <cfproperty fieldtype="column" name="tag_category_id" column="tag_category_id">     
    <cfproperty fieldtype="many-to-one" name="category" cfc="tag_category" fetch="join">
</cfcomponent>

这是 tag_category 表:

<cfcomponent output="false" persistent="true" entityname="tag_category" table="tag_category">
    <cfproperty fieldtype="id" name="id" column="tag_category_id">
    <cfproperty fieldtype="column" name="tag_category_name" column="tag_category_name">
</cfcomponent>

当我运行 EntityLoad("tag") 并转储结果时,我看到标记表的内容,但列出了类别属性作为空字符串。当我查看执行的 SQL 时,发现只有一个没有连接的简单查询。最后,当我打开保存映射并查看生成的 Hibernate XML 时,没有指定任何关系。这是怎么回事?我怎样才能让它发挥作用?

I'm setting up ORM in a ColdFusion app that runs against an Oracle 11g database (using the Oracle10g dialect in application.cfc), but the relationships aren't loading. Here are the mappings I have setup. This is a tag table with a foreign key into the tag_category table:

<cfcomponent output="false" persistent="true" entityname="tag" table="tag">
    <cfproperty fieldtype="id" name="id" column="tag_id">
    <cfproperty fieldtype="column" name="tag_name" column="tag_name">
    <cfproperty fieldtype="column" name="tag_category_id" column="tag_category_id">     
    <cfproperty fieldtype="many-to-one" name="category" cfc="tag_category" fetch="join">
</cfcomponent>

and here is the tag_category table:

<cfcomponent output="false" persistent="true" entityname="tag_category" table="tag_category">
    <cfproperty fieldtype="id" name="id" column="tag_category_id">
    <cfproperty fieldtype="column" name="tag_category_name" column="tag_category_name">
</cfcomponent>

When I run EntityLoad("tag") and dump the results, I see the contents of the tag table, but the category property is listed as an empty string. When I look at the SQL that's executed, there is only a simple query with no joins. And finally, when I turn on savemapping and look at the Hibernate XML that is generated, no relationships are specified. What's going on? How can I get this to work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦回梦里 2024-12-28 09:34:03

刚刚想通了。我在 application.cfc 中设置了 savemapping="true",这会生成一批 Hibernate XML 配置文件。当我更新 CFC 时,ColdFusion 仍然使用 Hibernate XML 文件作为配置源,而不是更新的 CFC。我假设每次执行 ormReload() 时都会重新生成 XML 文件,但事实似乎并非如此。

Just figured it out. I had set savemapping="true" in my application.cfc, which generated a batch of Hibernate XML configuration files. When I updated the CFCs, ColdFusion was still using the Hibernate XML files as the configuration source instead of the updated CFCs. I was assuming the XML files would be regenerated each time I did an ormReload(), but it appears not.

撕心裂肺的伤痛 2024-12-28 09:34:03

我认为您需要将延迟加载设置为 false,因为默认情况下它是 true,如下所示:

<cfproperty fieldtype="many-to-one" name="category" cfc="tag_category" fetch="join" lazy="false">

查看 cfdocs ,延迟加载 部分。

I think you need to set lazy loading to false as it is true by default, like so:

<cfproperty fieldtype="many-to-one" name="category" cfc="tag_category" fetch="join" lazy="false">

Check out the cfdocs, lazy loading section.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文