Our Work

Liferay DXP - Service Builder Custom Queries

Updated today


  • Liferay provides Service Builder modules to implement our own persistence layer.
  • In fact it is very reliable persistence business logic for your application. Writing persistence logic in your own way will take lot of time and effort.
  • Service Builder module provides some limited way of Finder implementation.
  • We might have some scenarios where we require to build our own service to fetch or find data from a custom query.
  • We don’t have exact way to do this step. But it’s possible to execute our own queries inside Service Builder to server our requirement to find or fetch data using a customer query.
  • Custom query can be implemented in either sql or hql.


  • Inside Service Builder create an create an FinderImpl Class in persistence.impl Package Of a Service Builder.
  • Build Service Builder and Extend the EnitityFinderBaseImpl Class and implement Enrityfinder Interface
  • Then Create A method & Call to Queries Using Service Builder Session Object
  • Create a Folder custom-sql in Meta-Inf folder
  • Create file default.xml in that folder and add Sql Queries By giving Unique Id
  • Get the Queries in FinderImpl Class Methods Using the Unique Id

Custom Query

  • In default.xml file create a custom query as below
  • That’s it, you can get the data from Service Builder API by executing above query,
  • And you can create hql query as well in sql-query place.

Looking for Liferay Developer?

KTree is the best offshore Liferay development company with extensive experience in Liferay Portal Development services along with Upgrade & Migration. Hire Liferay developers or Liferay development services from LiferayDeveloper.

Request For Quote


    No tag results found for this post