Custom query
A custom query allows creating dynamic criteria, like dynamic query API. In many situations, this avoids the need to create a custom query completely. However, in some cases, a custom query, called custom-sql, could be useful. For instance, there is a complex JOIN query and it is hard to do in the dynamic query API. In this case, custom query would be very helpful.
Let's consider a real example. A query says "find me all the articles with a specific companyId
and groupId
, subscribed to by a specific user, ordered by createDate
". Of course, you could use the dynamic query API. Here, we are using this request as an example to show how to build a custom query in the Plugins SDK.
In general, you should be able to build a custom query in the Plugins SDK in five steps:
1. Create a folder named
custom-sql
under$PLUGINS_SDK_HOME/portlets/${portlet.name}/docroot/WEB-INF/src
and create a file nameddefault.xml
undercustom-sql
with the following lines:<?xml version="1.0"?> <...