Finder methods retrieve entity objects from the database based on specified parameters. You’ll probably want to create at least one finder method for each entity you create in your services. Service Builder generates several methods based on each finder you create for an entity. It creates methods to fetch, find, remove, and count entity instances based on the finder’s parameters.
For many applications, it’s important to be able to find its entities per site.
You can specify these finders using Liferay Dev Studio DXP’s Overview mode for the
Here are the steps for creating a finder node:
Select the Finders node under the entity node in the Outline on the left side of the screen. The IDE displays an empty Finders table in the main part of the view.
Create a new finder by clicking the Add icon () to the right of the table.
Specify your finder’s name and return type. Use the Java camel-case naming convention when naming finders since the finder’s name is used to name the methods that Service Builder creates.
The IDE creates a new finder sub-node under the Finders node in the outline. Next, you’ll learn how to specify the finder column for this node.
Under the new finder node, Dev Studio DXP created a Finder Columns node. Here are the steps for creating finder columns:
Select the Finder Columns node to specify the columns for your finder’s parameters.
Create a new finder column by clicking the Add icon and specifying the column’s name. Keep in mind that you can specify multiple finder parameters (columns).
If you’re creating site-scoped entities (entities whose data should be unique to
each site), follow the steps described above to create finders by
retrieving your entities.
Service Builder generates finder-related methods (e.g.,
countByGroupId) for the your entities in
*PersistenceImpl classes. The first of these classes is
the interface; the second is its implementation. For example, Liferay’s
Bookmarks application generates its entity finder methods in the
classes found in the
-PersistenceImpl classes in the
Now you know to configure Service Builder to create finder methods for your entity. Terrific!
Now that you’ve specified the service for your project, you’re ready to build the service by running Service Builder. It’s time to run Service Builder and examine the code it generates.