Liferay has a mechanism called Service Builder, which hides database access as access to the model, but it is not necessary to create a record in the database, but an empty service is required for the following reasons There is.
At that time, you can create a service that does not create records in the database by the following method. However, the table will be created in the database.
--As usual, create Liferay Workspace with Liferay IDE / Liferay Developer Studio / Blade tools. See the User Guide (https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/creating-a-liferay-workspace-with-liferay-ide) for more information.
--Go to $ {liferay_workspace_root} / modules and create a service with Service Builder. Here, as an example, type the command blade create -t service-builder -p com.liferay.test tasks` `` to create a service. --The tasks folder will be created, so open
tasks / tasks-service / service.xml --
<entity local-service =" true "name =" Foo "remote-service =" true "uuid =" true "> ``` in the line of
`uuid =" true "
Change to `ʻuuid =" false "``` and delete all field definitions. The code looks like this
service.xml
<?xml version="1.0"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_0_0.dtd">
<service-builder package-path="com.liferay.test">
<namespace>FOO</namespace>
<!--<entity data-source="sampleDataSource" local-service="true" name="Foo" remote-service="false" session-factory="sampleSessionFactory" table="foo" tx-manager="sampleTransactionManager uuid="true"">-->
<entity local-service="true" name="Foo" remote-service="true" uuid="false">
</entity>
</service-builder>
--When you run gradle buildService
, the service will be created with an empty model.
--After that, just like the service generated by normal Service Builder, write the method in * LocalServiceImpl.java, * ServiceImpl.java and run `` `gradle buildService``` again, and the corresponding interface will be automatic. Will be generated.
Recommended Posts