Liferay 之 二 增删改查
程序员文章站
2022-07-15 13:39:05
...
1. Liferay 连接MySQL数据库, 创建配置文件
1.1 文件名: portal-ext.properties
1.2 文件路径: Liferay bundle 根目录
1.3 内容
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost:3306/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=123456
2. 使用Service Builder生成数据基本操作的代码
2.1 右键项目,选择创建Liferay Service Builder. 生成的service.xml默认路径是docroot/WEB-INF
2.2 service.xml 内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
<service-builder package-path="com.project.gen">
<author>juhu</author>
<namespace>PR</namespace>
<entity name="PRProduct" local-service="true" remote-service="false">
<column name="productId" type="long" primary="true" />
<column name="productName" type="String" />
<column name="serialNumber" type="String" />
<column name="companyId" type="long" />
<column name="groupId" type="long" />
<order by="asc">
<order-column name="productName"></order-column>
</order>
<finder return-type="Collection" name="G_PN">
<finder-column name="groupId" />
<finder-column name="productName" />
</finder>
<finder return-type="Collection" name="GroupId">
<finder-column name="groupId" />
</finder>
<finder return-type="Collection" name="CompanyId">
<finder-column name="companyId" />
</finder>
</entity>
</service-builder>
2.3 运行service.xml文件。 右键Liferay/build service
2.4 A lot of code will be generated including model code, service code, table sql etc. For the generated code, what we should focus on is com/project/gen/service/impl/xxxLocalServiceImpl.java file and add the logic method here.
public class xxxLocalServiceImpl extends xxxLocalServiceBaseImpl {
}
3. Create portlets.
3.1 Right click project to create a new portlet.
3.2
推荐阅读
-
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之增删改视图(八)
-
Android之采用execSQL与rawQuery方法完成数据的添删改查操作详解
-
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之菜单与测试(九)
-
常用操作之增、删、改、查
-
abp(net core)+easyui+efcore实现仓储管理系统——ABP WebAPI与EasyUI结合增删改查之四(三十)
-
PHP操作xml学习笔记之增删改查(1)—增加
-
JS数组操作之增删改查的简单实现
-
Mybatis框架二:增删改查
-
Mybatis框架学习之增删改查
-
MySQL基本语法之增删改查操作讲解