[JAVA] Create a Service with an empty model Liferay 7.0 / DXP

Cases that require empty service

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.

  1. Web API required
  2. If you want to combine multiple other services and treat them as one transaction (when a user is registered, create a site at the same time), the user management service and the site management service can be combined in one transaction. Need to handle, etc.)
  3. I want to create a custom service without database access. (Perform calculation processing, perform character string processing, etc.)

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.

Generation procedure

--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


<?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">
	<!--<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">

--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

Create a Service with an empty model Liferay 7.0 / DXP
Create a user with an empty password on CentOS7
How to create a service builder portlet in Liferay 7 / DXP
How to create a theme in Liferay 7 / DXP
Create an EC site with Rails5 ⑤ ~ Customer model ~
Create an EC site with Rails5 ⑦ ~ Address, Genre model ~
Create an EC site with Rails 5 ⑨ ~ Create a cart function ~
Create a playground with Xcode 12
Create an immutable class with JAVA
Create a Vue3 environment with Docker!
Create an app with Spring Boot 2
Create an app with Spring Boot
Create exceptions with a fluid interface
Create a Maven project with a command
I tried to create an API to get data from a spreadsheet in Ruby (with service account)
Create an EC site with Rails5 ③-Set model associations and other things-
[Java] Create an executable module with Gradle
Create a jar file with the command
[Rails6] Create a new app with Rails [Beginner]
Create a simple web application with Dropwizard
Create a simple on-demand batch with Spring Batch
Create a GUI JSON Viewer with Ruby/GTK3
Create a MySQL environment with Docker from 0-> 1
Create a simple bar chart with MPAndroidChart
Create a temporary class with new Object () {}
[Rails 5] Create a new app with Rails [Beginner]
Create an or search function with Ransack.
A simple example of an MVC model
How to create an Excel form using a template file with Spring MVC
Create a website with Spring Boot + Gradle (jdk1.8.x)
[Memo] Create a CentOS 8 environment easily with Docker
Create a simple search app with Spring Boot
Create a CSR with extended information in Java
Create a simple bulletin board with Java + MySQL
[Rails] rails new to create a database with PostgreSQL
[Windows] [IntelliJ] [Java] [Tomcat] Create a Tomcat9 environment with IntelliJ
Let's create a timed process with Java Timer! !!
Create an RSA encryption-enabled JSON API with wicket
Let's create a RESTful email sending service + client
[Java] Create a collection with only one element
Create a team chat with Rails Action Cable
Create a SandBox account with fastlane spaces ip
Create a multi-key map with the standard library
Create an Annotator that uses kuromoji with NLP4J [007]
How to create member variables with JPA Model
[Swift] Create an image selection UI with PhotoKit
Create a web api server with spring boot
Create an EC site with Rails 5 ⑩ ~ Create an order function ~
Create a Spring Boot development environment with docker