フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Gordon Augat
Service Builder not creating Finder Methods in *ServiceUtil Class
2010/03/29 17:09
答え

Gordon Augat

ランク: Junior Member

投稿: 99

参加年月日: 2006/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
Pravin Pawar
RE: Service Builder not creating Finder Methods in *ServiceUtil Class
2013/02/14 19:57
答え

Pravin Pawar

ランク: Junior Member

投稿: 62

参加年月日: 2009/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

 1package com.liferay.sampleservicebuilder.service.impl;
 2
 3import java.util.List;
 4import com.liferay.portal.SystemException;
 5import com.liferay.sampleservicebuilder.model.Foo;
 6import com.liferay.sampleservicebuilder.service.base.FooLocalServiceBaseImpl;
 7import com.liferay.sampleservicebuilder.service.persistence.FooUtil;
 8
 9/**
10 * <a href="FooLocalServiceImpl.java.html"><b><i>View Source</i></b></a>
11 *
12 * @author Brian Wing Shun Chan
13 *
14 */
15public class FooLocalServiceImpl extends FooLocalServiceBaseImpl {
16    public List<Foo> getByField2(boolean field2)
17    throws SystemException {
18
19        return FooUtil.findByField2(field2);
20    }
21}


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
Pius Onobhayedo
RE: Service Builder not creating Finder Methods in *ServiceUtil Class
2010/07/29 3:46
答え

Pius Onobhayedo

ランク: Junior Member

投稿: 25

参加年月日: 2009/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.
Shagul Khajamohideen
RE: Service Builder not creating Finder Methods in *ServiceUtil Class
2010/07/29 4:06
答え

Shagul Khajamohideen

ランク: Liferay Master

投稿: 759

参加年月日: 2007/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.
Pius Onobhayedo
RE: Service Builder not creating Finder Methods in *ServiceUtil Class
2010/07/29 8:12
答え

Pius Onobhayedo

ランク: Junior Member

投稿: 25

参加年月日: 2009/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.
Raghu k
RE: Service Builder not creating Finder Methods in *ServiceUtil Class
2013/02/06 6:46
答え

Raghu k

ランク: Junior Member

投稿: 58

参加年月日: 2012/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>
Chirag Patadia
RE: Service Builder not creating Finder Methods in *ServiceUtil Class
2013/02/06 2:03
答え

Chirag Patadia

ランク: Junior Member

投稿: 29

参加年月日: 2012/02/02

最近の投稿

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.

1
2    public java.util.List<com.getransportation.cwc.webleads.model.Favorites> findByallFilesForUGC(
3            long USERID, long GROUPID, long COMPANYID)
4            throws com.liferay.portal.kernel.exception.SystemException {
5        return favoritesPersistence.findByallFilesForUGC(USERID, GROUPID, COMPANYID);
6    }


Best Regards,
Chirag Patadia.