2011-12-13 31 views
2

我在一個針對Oracle 11g數據庫運行的ColdFusion應用程序(在application.cfc中使用Oracle10g方言)中設置ORM,但沒有加載關係。這裏是我設置的映射。這是一個外鍵進入tag_category表變量表:讓ORM在ColdFusion中工作9

<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(「標籤」)和dump結果,我請參閱標記表的內容,但category屬性列爲空字符串。當我查看執行的SQL時,只有一個簡單的查詢,沒有連接。最後,當我打開savemapping並查看生成的Hibernate XML時,沒有指定任何關係。這是怎麼回事?我怎樣才能使這個工作?

回答

2

只是想通了。我在application.cfc中設置了savemapping =「true」,它生成了一批Hibernate XML配置文件。當我更新CFC時,ColdFusion仍然使用Hibernate XML文件作爲配置源,而不是更新的CFC。我假設每次執行ormReload()時都會重新生成XML文件,但似乎沒有。

0

我認爲你需要延遲加載設置爲false,因爲它默認爲true,像這樣:

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

退房的cfdocs,延遲加載部分。