Fórum

List <> Return type is incompatible with function()

Florian Emanuel, modificado 7 Anos atrás.

List <> Return type is incompatible with function()

New Member Postagens: 2 Data de Entrada: 07/04/16 Postagens Recentes
Hello, i am new to liferay development and i am trying to develp a portlet. i have gone through the learning path and i am now trying to apply the code from the guestbook learning path to my needs.

I have set up my datamodel using the liferay service builder and am now trying to implement the LocalServiceImpl just as it is shown in the learning path (https://dev.liferay.com/develop/learning-paths/mvc/-/knowledge_base/6-2/integrating-your-persistence-framework-into-your-a)

why does the first function give me the error: "The return type is incompatible with FehlerLocalServiceBaseImpl.getFehler(long)" while the second function works?
what is different from the guestbook learning path?
thanks for your help!
thumbnail
Pankaj Kathiriya, modificado 7 Anos atrás.

RE: List <> Return type is incompatible with function()

Liferay Master Postagens: 722 Data de Entrada: 05/08/10 Postagens Recentes
Well first method must be returning something which is not list of Fehler objects.
e.g It should be returning just one Fehler Object.

OR
You could build service again and refresh your workspace, if its not the above issue.
thumbnail
David H Nebinger, modificado 7 Anos atrás.

RE: List <> Return type is incompatible with function()

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
Yeah, so if you create a method, public int getFehler() in your FehlerLocalServiceImpl class and then build services, SB adds a method to FehlerLocalService with the same signature.

Since FehlerLocalServiceImpl implements FehlerLocalService, all is good.

But when you change to public List<Fehler> getFehler() in FehlerLocalServiceImpl, the method signature no longer matches the interface and javac will give you this message.

When you rebuild services, SB will change the method in FehlerLocalService and javac will be happy again.

Whenever you change a method signature or you add/remove methods from XxxLocalServiceImpl, you have to rebuild services for all of the interfaces to be updated.
Florian Emanuel, modificado 7 Anos atrás.

RE: List <> Return type is incompatible with function()

New Member Postagens: 2 Data de Entrada: 07/04/16 Postagens Recentes
thank you for the replys