Foros de discusión

List <> Return type is incompatible with function()

Florian Emanuel, modificado hace 7 años.

List <> Return type is incompatible with function()

New Member Mensajes: 2 Fecha de incorporación: 7/04/16 Mensajes recientes
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!

Archivos adjuntos:

thumbnail
Pankaj Kathiriya, modificado hace 7 años.

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

Liferay Master Mensajes: 722 Fecha de incorporación: 5/08/10 Mensajes recientes
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 hace 7 años.

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

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
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 hace 7 años.

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

New Member Mensajes: 2 Fecha de incorporación: 7/04/16 Mensajes recientes
thank you for the replys