掲示板

Service Builder not creating Finder Methods in *ServiceUtil Class

thumbnail
14年前 に Gordon Augat によって更新されました。

Service Builder not creating Finder Methods in *ServiceUtil Class

Regular Member 投稿: 107 参加年月日: 06/08/16 最新の投稿
I am using the plugin sdk from the 5.2.x branch. When I run "ant build-service", it does not create any static finder methods in the *ServiceUtil classes for my service. I have verified this with the sample-service-builder-portlet as well. The service.xml files has this entry...

<finder name="Field2" return-type="Collection">
<finder-column name="field2" />
</finder>

Shouldn't the following files have static finder methods?

portlets\sample-service-builder-portlet\docroot\WEB-INF\service\com\liferay\sampleservicebuilder\service\FooLocalService.java

portlets\sample-service-builder-portlet\docroot\WEB-INF\service\com\liferay\sampleservicebuilder\service\FooLocalServiceUtil.java
thumbnail
14年前 に Pravin Pawar によって更新されました。

RE: Service Builder not creating Finder Methods in *ServiceUtil Class

Junior Member 投稿: 62 参加年月日: 09/11/17 最新の投稿
Hi Gordon,
I have just run the build-service command with sample-service-builder-portlet. The finder methods for Field2 are shown in \sample-service-builder-portlet\docroot\WEB-INF\service\com\liferay\sampleservicebuilder\service\persistence\FooUtil.java

When I run "ant build-service", it does not create any static finder methods in the *ServiceUtil classes for my service


For using this methods you need to add below code in FooLocalServiceImpl.java

package com.liferay.sampleservicebuilder.service.impl;

import java.util.List;
import com.liferay.portal.SystemException;
import com.liferay.sampleservicebuilder.model.Foo;
import com.liferay.sampleservicebuilder.service.base.FooLocalServiceBaseImpl;
import com.liferay.sampleservicebuilder.service.persistence.FooUtil;

/**
 * <a href="FooLocalServiceImpl.java.html"><b><i>View Source</i></b></a>
 *
 * @author Brian Wing Shun Chan
 *
 */
public class FooLocalServiceImpl extends FooLocalServiceBaseImpl {
	public List<foo> getByField2(boolean field2)
	throws SystemException {

		return FooUtil.findByField2(field2);
	}
}</foo>


Once this done, generate service layer again by executing build-service ant task.

Now you will get the finder methods for Field2 in files you have specified as

portlets\sample-service-builder-portlet\docroot\WEB-INF\service\com\liferay\sampleservicebuilder\service\FooLocalService.java

portlets\sample-service-builder-portlet\docroot\WEB-INF\service\com\liferay\sampleservicebuilder\service\FooLocalServiceUtil.java
thumbnail
13年前 に Pius Onobhayedo によって更新されました。

RE: Service Builder not creating Finder Methods in *ServiceUtil Class

Junior Member 投稿: 25 参加年月日: 09/04/23 最新の投稿
Hello,

Does this imply that the finders indicated in the service.xml are not automatically generated unless the corresponding methods are manually written in the service impl classes? Or is there an option for turning on the automatic generation of all the finders indicated in the service.xml?

Thank you.
thumbnail
13年前 に Shagul Khajamohideen によって更新されました。

RE: Service Builder not creating Finder Methods in *ServiceUtil Class

Liferay Master 投稿: 758 参加年月日: 07/09/27 最新の投稿
I don't think there is an option to do have finder methods automatically wrapped in the LocalServieUtil. The methods are generated in the persistenceImpl and you need to make a single line call in localserviceImpl and rerun the service builder to update the utils and all interfaces. Looks like a great idea to have an option like that.

The best reference is liferay-service-builder_version.dtd in the Liferay source.
thumbnail
13年前 に Pius Onobhayedo によって更新されました。

RE: Service Builder not creating Finder Methods in *ServiceUtil Class

Junior Member 投稿: 25 参加年月日: 09/04/23 最新の投稿
Thanks Shagul for the feedback. I agree with you that it would be an interesting feature to have the option to autogenerate the finders already manually entered in the service.xml.
11年前 に Raghu k によって更新されました。

RE: Service Builder not creating Finder Methods in *ServiceUtil Class

Junior Member 投稿: 58 参加年月日: 12/08/10 最新の投稿
Hi Pravin Pawar,
I created an entity for Favorites. I added finders in my service.xml. After build, I got finders in FavoritesUtil class which is in persistence package. In order to use them I added one finder method as you said in FavoritesLocalServiceImpl and did service-build. This dint generate my method in FavoritesLocalServiceUtil.
Below is the code snippet. Can you please help me here.

Service.xml
<entity name="Favorites" local-service="true" remote-service="false" table="FAVORITE_DOCUMENTS">
<!-- PK fields -->
<column name="GROUPID" type="long" primary="true"></column>
<column name="COMPANYID" type="long" primary="true"></column>
<column name="USERID" type="long" primary="true"></column>
<column name="FILEENTRYID" type="long" primary="true"></column>
<!-- UI fields -->

<column name="CREATEDATE" type="Date"></column>

<finder name="GroupId" return-type="Collection">
<finder-column name="GROUPID" />
</finder>
<finder name="CompanyId" return-type="Collection">
<finder-column name="COMPANYID" />
</finder>
<finder name="UserId" return-type="Collection">
<finder-column name="USERID" />
</finder>
<finder name="singleFileOfUser" return-type="Collection">
<finder-column name="USERID" />
<finder-column name="GROUPID" />
<finder-column name="COMPANYID" />
<finder-column name="FILEENTRYID" />
</finder>
<finder name="allFilesForUGC" return-type="Collection">
<finder-column name="USERID" />
<finder-column name="GROUPID" />
<finder-column name="COMPANYID" />
</finder>
Nee method which i added in FavoritesLocalServiceImpl:
public java.util.List<com.gettingtransport.cwc.webleads.model.Favorites> findByallFilesForUGC(
long USERID, long GROUPID, long COMPANYID)
throws com.liferay.portal.kernel.exception.SystemException {
return FavoritesUtil.findByallFilesForUGC(USERID, GROUPID, COMPANYID);
}

</entity>
thumbnail
11年前 に Chirag Patadia によって更新されました。

RE: Service Builder not creating Finder Methods in *ServiceUtil Class

Junior Member 投稿: 29 参加年月日: 12/02/03 最新の投稿
Hi Raghu,

If you check your FavoritesLocalServiceImpl class it extends FavoritesLocalServiceBaseImpl. If you check FavoritesLocalServiceBaseImpl file you can find favoritesPersistence object. So you need to call your finder method like as follows (i.e. using persistence object only) and by this way you can get data from the table as per finder method which has been generated by service-builder.

For your quick reference check below code snippet, which you should try.


	public java.util.List<com.getransportation.cwc.webleads.model.favorites> findByallFilesForUGC(
			long USERID, long GROUPID, long COMPANYID)
			throws com.liferay.portal.kernel.exception.SystemException {
		return favoritesPersistence.findByallFilesForUGC(USERID, GROUPID, COMPANYID);
	}
</com.getransportation.cwc.webleads.model.favorites>


Best Regards,
Chirag Patadia.