通过配置service.xml 实现
说明:一对多和多对多关系,build-service 后会在persistence层
自动生成contain, count 和 find 方法, 需要手动在service层添加对这些方法的调用。
多对多:
例如 user与Group 的多对多关系, 关联表为Users_Groups
<column name="groups" type="Collection" entity="Group" mapping-table="Users_Groups" />
一对多:
例如skuAttribute与skuAttributeOption之间存在一对多关系
<column name="options" type="Collection" entity="SKUAttributeOption" mapping-key="skuAttributeId" />
自动生成的方法如下
//contain 方法
skuAttributePersistence.containsSKUAttributeOptions(pk);
skuAttributePersistence.containsSKUAttributeOption(pk, skuAttributeOptionPK);
//count 方法
skuAttributePersistence.getSKUAttributeOptionsSize(pk);
//finnd 方法
skuAttributePersistence.getSKUAttributeOptions(pk, start, end);
(一)多对多关系参考代码:
参考 liferay源码\portal-impl\src\com\liferay\portal\service.xml
<entity name="User" uuid="true" local-service="true" remote-service="true">
<!-- PK fields -->
<column name="userId" type="long" primary="true" />
<!-- Audit fields -->
<column name="companyId" type="long" />
<column name="createDate" type="Date" />
<column name="modifiedDate" type="Date" />
<!-- Other fields -->
<column name="defaultUser" type="boolean" />
<column name="contactId" type="long" />
<!-- Relationships -->
<column name="groups" type="Collection" entity="Group" mapping-table="Users_Groups" />
<column name="orgs" type="Collection" entity="Organization" mapping-table="Users_Orgs" />
<!-- Finder methods -->
<!-- References -->
<reference package-path="com.liferay.mail" entity="Mail" />
<reference package-path="com.liferay.portlet.announcements" entity="AnnouncementsDelivery" />
</entity>
(二)一对多关系 参考代码
<entity name="SKUAttribute" local-service="true" remote-service="false">
<column name="skuAttributeId" type="long" primary="true" />
<column name="name" type="String" />
<!-- Relationships -->
<column name="options" type="Collection" entity="SKUAttributeOption" mapping-key="skuAttributeId" />
<!-- order -->
<!-- finder-->
</entity>
<entity name="SKUAttributeOption" local-service="true" remote-service="false">
<column name="skuAttributeOptionId" type="long" primary="true" />
<column name="skuAttributeId" type="long" />
<column name="name" type="String" />
</entity>
相关推荐
liferay-portal-sql-6.1.1-ce-ga2-20120731132656558
liferay-plugins-sdk-6.1.1-20130816114619181.zip是liferay开发中不可缺少的文件,还有src文件,liferay-eclipse等
liferay-service-builder_6_2_0
liferay-plugins-sdk-6.2.0-ce-m4 最新版本。
liferay-ide-eclipse-updatesite-1.6.2
liferay-portal-src-6.0.6-20110225.part2
liferay developer guide
spdf.zip,spdfquickly在命令行上创建pdf
话不多说,好东西 一句话,适合liferay开发
liferay提供了插件的机制,通过插件,开发人员可以方便的构造出一个portlet、theme的框架,进而对它增加具体的业务逻辑,以完成符合自己需要的功能。
liferay的eclipse插件,用于在eclipse集成环境中进行liferay代码调试、编程,增加了代码的编写效率。
liferay-administration-guide liferay-administration-guide
import com.liferay.portal.kernel.util.StringBundler; StringBundler jsonStr1 = new StringBundler(150); 操作如StringBuilder,相同
liferay-developer-guide-6.0
Liferay 批量添加用户 liferay : liferay-portal-6.1.1-ce-ga2
liferay 学习 Liferay-使用手册.pdf
liferay-portal详解
管理员文档 liferay administration guide
liferay-installation-guide-4.2.pdf
seo with liferay portal