2012-01-11 1 views
2

私はSQLで数秒かかる基本的な結合をしようとしていますが、私はORMExecuteQuery(Hibernateに基づくColdfusion 9)で動作させようとしています。coldfusion fw1(hibernate)テーブル間の基本的な結合 - "結合が期待されるパス!"

私は3つのオブジェクトがあります を - にお問い合わせください - ContactCategory_Link - ContactCategory

コンポーネントの詳細は、働いていると何が働いていないものの簡単な説明の後に続きます。

基本的に連絡先には多くのカテゴリがあり、カテゴリにも多くの連絡先があります。 すべてのリンクに異なるパラメータを追加する必要があるため(たとえば、各連絡先のカテゴリを注文する必要があります(エンドユーザーはカテゴリを並べ替えることができなければなりません)。 多対多の関係は、そのような追加情報を追加することはできないように思われるため、多対多の関係は使用しませんでした。だからここ

は完璧に動作要求である:

<cfset response["rows"] = ORMExecuteQuery(" 
     SELECT new map(c.name as Name) 
     FROM Contact c 
     ")> 

それは完全に連絡先の名前を与えます。 ただし、別のテーブルを追加しようとするたびに失敗します。たとえば :

<cfset response["rows"] = ORMExecuteQuery(" 
     SELECT new map(c.name as Name) 
     FROM Contact c 
     JOIN ContactCategory_Link 
     ")> 

が得られます:だから私は、私を推測している

Invalid path: 'null.contact' 

Path expected for join! 

を私はContactCategory_Link.contactためContactCategory_Linkを変更していたとしても、それはのようなものを与えますコンポーネントCFCは正しく設定されていませんが、理由はわかりません。

この件に関するお手伝いをしてください。あなたの助けのための

<cfcomponent displayname="Contact" entityname="Contact" table="step8_contact" persistent="true" output="false"> 

<cfproperty name="id" column="contactID" type="guid" fieldtype="id" setter="false" unique="true" notnull="true" generated="insert" generator="identity"> 

<cfproperty name="name" column="name" type="string" length="125" required="true"> 

<cfproperty name="categories" fieldtype="one-to-many" singularname="category" fkcolumn="contactID" cfc="ContactCategory_Link" missingRowIgnored="true" cascade="all-delete-orphan"> 

</cfcomponent> 

<cfcomponent displayname="ContactCategory_Link" entityname="ContactCategory_Link" table="step8_contactcategory_link" persistent="true" output="false"> 

<cfproperty name="id" column="contactcategory_linkID" type="numeric" fieldtype="id" setter="false" unique="true" notnull="true" generated="insert" generator="identity"> 

<cfproperty name="orderId" column="orderId" type="numeric" required="true"> <!---notnull="true"---> 

<cfproperty name="contact" fieldtype="many-to-one" fkcolumn="contactID" cfc="Contact" missingRowIgnored="true"> 
<cfproperty name="contactcategory" fieldtype="many-to-one" fkcolumn="contactcategoryID" cfc="ContactCategory" missingRowIgnored="true"> 

</cfcomponent> 

<cfcomponent displayname="ContactCategory" output="false" persistent="true" entityname="ContactCategory" table="step8_contactcategories" hint="" cacheuse="read-only" cachename="contactcategory"> 

<cfproperty name="id" column="contactcategoryID" type="numeric" fieldtype="id" setter="false" unique="true" notnull="true" generated="insert" generator="identity"> 
<cfproperty name="label" column="label" type="string" length="255" required="true" notnull="true"> 
<cfproperty name="orderId" column="orderId" type="numeric" required="true" notnull="true"> 

<cfproperty name="categories" fieldtype="one-to-many" singularname="category" fkcolumn="contactcategoryID" cfc="ContactCategory_Link" missingRowIgnored="true" cascade="all-delete-orphan" lazy="true"> 
</cfcomponent> 

ありがとう:


は、ここで、各オブジェクトのコードです。

答えて

1

cfsetはおそらくhql-query(ハイバネートクエリ言語=オブジェクトクエリ言語)です。あなたは必要があります

<cfset response["rows"] = ORMExecuteQuery(" 
    SELECT c.name as Name, cat.whatever as Whatever 
    FROM Contact c 
    JOIN c.Categories cat 
    ")> 
+0

私はあなたの助けを借りて解決策を見つけることができました! ありがとうございました! ) このリクエストはすべての問題を解決しました:

関連する問題