In this tutorial, you’ll learn how to define an object relational map so your application can persist data. As an example, you’ll examine the existing Liferay Bookmarks application that uses Service Builder.
The Bookmarks application bookmarks assets in Liferay. The application defines two entities, or model types, to represent an organization’s bookmarks and their folders. These entities are called bookmark entries and bookmark folders. Since a bookmark must have a folder (even if it’s a root folder), the entry entity references a folder entity as one of its attributes.
The Bookmarks application’s source code resides in the
bookmarks-web modules. Notice the
BookmarksPortlet.java files in the
com.liferay.bookmarks.web.portlet package in the
These portlet classes extend Liferay’s
They act as the controllers in the MVC pattern. These classes contain the
business logic that invokes the Service Builder generated bookmarks services
that you’ll learn how to create in this section. The application’s view layer is
implemented in the JSPs in the
This tutorial assumes your application has these types of modules :
*-api: Service interfaces
*-service: Service implementations
*-web: Portlet and controller
The parent folder of these modules is the application folder. The
Service Builder project template
is available for creating the
*-service modules. Client UI project
templates such as the
are available for creating the
*-web module. You can create projects from
both templates using either Dev Studio DXP or Blade.
The first step in using Service Builder is to define your model classes and
their attributes in a
service.xml file. This file typically resides
*-service module’s root folder, although you can configure your
build tool to recognize it in other folders. Service Builder
terminology calls model classes entities. For example, the Bookmarks
application has two entities:
requirements for each are defined in the
listed in the
<column /> elements.
Once Service Builder reads the
service.xml file, you can define your entities.
Liferay Dev Studio DXP
makes it easy to define entities in your application’s
Follow these steps:
Each step is explained in detail. Start with creating a