ColdFusion FW1(Hibernate)テーブル間の基本結合 - 「参加に期待されるパス!」
-
27-10-2019 - |
質問
SQLで数秒かかる基本的な結合を試みていますが、... Ormexecutequery(Hibernateに基づいてColdFusion 9)で動作させようとしています。
3つのオブジェクトがあります:-Contact -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
")>
あげる:
Path expected for join!
私が変わっていても ContactCategory_Link
為に ContactCategory_Link.contact
, 、それは次のようなものを与えます:
Invalid path: 'null.contact'
だから私は自分のコンポーネント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>
ご協力いただきありがとうございます。
解決
CFSETはおそらくHQL-Queryです(Hibernate Query Language = Object Query Language)。必要がある
<cfset response["rows"] = ORMExecuteQuery("
SELECT c.name as Name, cat.whatever as Whatever
FROM Contact c
JOIN c.Categories cat
")>