Vincent
Vincent

Reputation: 139

Finder Util class not generated with Liferay 7 Service Builder

Whereas I had no problem with the Service Builder in Liferay 6.2, I meet a blocking issue in Liferay 7 when I am building service to generate my first Finder Util class. When I discover that, I even decided to start from scratch a project, the problem is still here. Even with the official doc, nothing works.

Does someone has any idea to help me ?

Here is the complete description for my last test in Eclipse Mars :

  1. Create a new Liferay Workspace
  2. Create a new Liferay Project Module Service Builder
  3. Create a foo object in service.xml
  4. Build services (class are well generated)
  5. Create manually a FooFinderImpl class in the persistence.impl package
  6. Build services
    The FooFinder interface is well generated but the FooFinderUtil class is not generated.
  7. Add some methods in the FooFinderImpl class
  8. Build services
  9. Nothing new

Thank you for you help.

Vincent

Upvotes: 2

Views: 1788

Answers (2)

Scott Lee
Scott Lee

Reputation: 1

From https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/custom-sql

Note: In previous versions of Liferay Portal, your finder methods were accessible via -FinderUtil utility classes. Finder methods are now injected into your app’s local services, removing the need to call finder utilities.

You should now be able to directly call your finder method in the service layer: fooFinder.findBy...

Upvotes: 0

Romeo Sheshi
Romeo Sheshi

Reputation: 931

When you build the service there are some properties in build.gradle so if you want to generate the Util class has to set osgiModule to false.

buildService {
    apiDir = "../foo-api/src/main/java"
    osgiModule = false
    propsUtil = "com.liferay.docs.foo.service.util.PropsUtil"
}

Otherwise if you want to use osgi you can retrive the finder this way

@Reference
private volatile FooFinder fooFinder;

or

@Reference(unbind = "-")
protected void setFooFinder(
        FooFinder fooFinder) {

    _fooFinder = fooFinder;
}

private FooFinder _fooFinder;

for more info see liferay-docs https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/finding-and-invoking-liferay-services

exampel on github http://github.com/bruinen/liferay-services-example

Upvotes: 2

Related Questions