锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
]]>
]]>
]]>
1錛氬湪service.xml涓厤緗?/span>
For example錛?/span>
<column
name="shoppingItemPrices"
type="Collection"
entity="ShoppingItemPrice"
mapping-key="itemId"
/>
璇存槑錛?/span> entity鍜?/span>mapping-key灞炴ц鎸囧畾灝嗗緩绔嬩竴涓竴瀵瑰鐨勫叧緋匯?/span>
2錛氳繍琛?/span>ant build
鐢熸垚鐩稿叧鏂囦歡
3錛氬湪鐢熸垚鐨勫疄浣撳疄鐜扮被涓紝濡?/span>ShoppingItemImp.java錛屾柊澧?/span>getShoppingItemPrice()鏂規(guī)硶
For example錛?/span>
public List getItemPrices()
throws PortalException, SystemException {
/*姝ゅreturn鏈?/span>2縐嶅啓娉?/span>
絎竴縐嶆槸瑕佹眰鍦ㄥ叧緋誨疄浣撲腑瀹氫箟鏍規(guī)嵁鍏寵仈瀹炰綋id榪涜鏌ヨ鐨勬柟娉曪紝濡傦細(xì)
*/
return ShoppingItemPriceLocalServiceUtil.getItemPrices(getItemId());
/*
絎簩縐嶆槸閫氳繃涓氬姟灞備唬鐞嗙被鑾風(fēng)殑瀹炰綋鐨勬寔涔呯被瀹炰緥榪涜鎿嶄綔
*/
return ActiveEntryLocalServiceUtil.getActiveEntryPersistence().getCheckItemEntries(this.getActiveId());
}
4錛氬啀嬈¤繍琛?/span> ant build
濡傛渚垮彲鍦ㄤ嬌鐢ㄥ疄浣撶殑鏃跺欑洿鎺ヨ幏鍙栧叧鑱斿璞″疄浣?/span>
濡傦細(xì)
List list = ActiveEntry.getCheckItemEntries ();
濡傛灉瑕佸湪hbm閰嶇疆鏂囦歡涓敓鎴愪竴瀵瑰鍏崇郴鎻忚堪錛屽垯闇淇敼freemarker妯℃澘鏂囦歡
鏂囦歡璺緞錛?/span>com/liferay/portal/tool/servicebuilder/dependencies/hbm_xml.flt
錛堝鏋滃鍏朵粬鐢熸垚鏂囦歡鍐呭鍋氳皟鏁達(dá)紝涔熷彲淇敼鍏朵粬瀵瑰簲鐨勬ā鏉挎枃浠訛級
淇敼涓哄涓嬪唴瀹癸紙涔熷彲鐩存帴copy錛?/span>
<#list entities as entity>
<#if entity.hasColumns()>
<class name="${packagePath}.model.impl.${entity.name}Impl" table="${entity.table}">
<cache usage="read-write" />
<#if entity.hasCompoundPK()>
<composite-id name="primaryKey" class="${packagePath}.service.persistence.${entity.name}PK">
<#assign pkList = entity.getPKList()>
<#list pkList as column>
<key-property name="${column.name}"
<#if column.name != column.DBName>
column="${column.DBName}"
</#if>
/>
</#list>
</composite-id>
<#else>
<#assign column = entity.getPKList()?first>
<id name="${column.name}"
<#if column.name != column.DBName>
column="${column.DBName}"
</#if>
type="<#if !entity.hasPrimitivePK()>java.lang.</#if>${column.type}">
<#if column.idType??>
<#assign class = serviceBuilder.getGeneratorClass("${column.idType}")>
<#if class == "class">
<#assign class = column.IdParam>
</#if>
<#else>
<#assign class = "assigned">
</#if>
<generator class="${class}"
<#if class == "sequence">
<param name="sequence">${column.IdParam}</param>
</generator>
<#else>
/>
</#if>
</id>
</#if>
<#list entity.columnList as column>
<#if column.EJBName??>
<#assign ejbName = true>
<#else>
<#assign ejbName = false>
</#if>
<#if !column.isPrimary() && !column.isCollection() && !ejbName>
<property name="${column.name}"
<#if column.name != column.DBName>
column="${column.DBName}"
</#if>
<#if column.isPrimitiveType() || column.type == "String">
type="com.liferay.util.dao.hibernate.${serviceBuilder.getPrimitiveObj("${column.type}")}Type"
</#if>
/>
</#if>
<#if !column.isPrimary() && column.isCollection()>
<#if column.isMappingOneToMany()>
<set name="${column.name}" lazy="true">
<key column="${column.getMappingKey()}"/>
<one-to-many class="${packagePath}.service.persistence.${column.EJBName}" />
</set>
</#if>
</#if>
</#list>
</class>
</#if>
</#list>