2017-08-02 36 views
0

我想在這裏實現的是從子實體加載一些字段。在Groovy服務中加載實體時包含子實體

例如,我們假設我想爲產品列表加載一些功能。在XML中這是很清楚的:

<row-actions> 
    <entity-find-one entity-name="mantle.product.feature.ProductFeature" value-field="brandList"> 
     <field-map field-name="productFeatureId" from="featureList.productFeatureId"/> 
     <field-map field-name="productFeatureTypeEnumId" from="featureList.productFeatureId" value="PftBrand"/> 
    </entity-find-one> 
</row-actions> 

有沒有辦法做到在Groovy類似的東西,而不需要通過整個產品目錄遍歷和手動添加所需的字段?

另外,有人可以給我一個簡短的例子,具體使用sqlFindhttp://www.moqui.org/javadoc/org/moqui/entity/EntityFacade.html)?

我試圖解決我問的關於使用連接查詢的問題,但我無法弄清楚SQL查詢應該如何看起來像。

回答

0

a。元素'entity-find-one'查詢主鍵並返回單個映射。你需要使用'entity-find'元素。

b。是的,你總是可以使用腳本標籤下降到常規。例如只需使用ec.entity.find("mantle.product.feature.ProductFeature")或任何你需要在你的groovy腳本。

c。在moqui中,連接表由'view-entity'元素處理,您可以預定義自己的(放置在'實體'文件夾中)或使用框架中提供的許多現有元素。你不需要SQL。

編輯 - 對不起,您還可以通過使用EntityFind.makeEntityDynamicView()方法實時執行此操作。

希望有所幫助。

相關問題