2
votes

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?

2

2 Answers

2
votes

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.

0
votes

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.