我有以下设置:
清单.cfc
component persistent="true"
{
property name="ListingId" column="ListingId" type="numeric" ormtype="int" fieldtype="id" generator="identity";
...
property name="Features" type="array" hint="Array of features" singularname="Feature" fieldtype="many-to-many" cfc="Feature" linktable="Listing_Feature" FKColumn="ListingId" inversejoincolumn="FeatureId";
}
特征.cfc
component persistent="true" table="Feature" schema="dbo" output="false"
{
property name="FeatureId" column="FeatureId" type="numeric" ormtype="int" fieldtype="id" generator="identity";
property name="FeatureDescription" column="FeatureDescription" type="string" ormtype="string";
...
/*property name="Listings" fieldtype="many-to-many" cfc="Listing" linktable="Listing_Feature" fkcolumn="FeatureId" inversejoincolumn="ListingId" lazy="true" cascade="all" orderby="GroupOrder";*/
}
我可以使用以下方法选择具有特定功能的所有列表:
<cfset matchingListings = ormExecuteQuery("from Listing l left join l.Features as feature where feature.FeatureId = :feature",{feature = 110}) />
这很好,但是,我希望能够选择所有具有多种功能的列表(例如同时具有“洗碗机”和“车库”的列表)
经过几个小时的谷歌搜索和查看休眠文档后,无法找到不会给我错误的解决方案。我的猜测是解决方案非常简单,我只是想多了……有人有什么建议吗?