Fórum

creating finderImpl if model is on imported jars (service-builder)

thumbnail
John Voltaire Maximo, modificado 8 Anos atrás.

creating finderImpl if model is on imported jars (service-builder)

Regular Member Postagens: 106 Data de Entrada: 19/06/15 Postagens Recentes
Hey guys,

I am using service builder to communicate to my database. thing is I am using the same tables for two of my portlets, so I imported the jar created in one of my portlets to the other one,,
but then I need to create a custom sql on both of them.. how do I create the finderImpl class? I don't have the persistence folder on my other portlet because the service.jar was only imported..
am I doing it right? what should I do with this?

thanks
thumbnail
Harish Kumar, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
John Voltaire Maximo:
Hey guys,

I am using service builder to communicate to my database. thing is I am using the same tables for two of my portlets, so I imported the jar created in one of my portlets to the other one,,
but then I need to create a custom sql on both of them.. how do I create the finderImpl class? I don't have the persistence folder on my other portlet because the service.jar was only imported..
am I doing it right? what should I do with this?

thanks


Hi

Instead of copy paste service jar, declare the dependency in liferay-plugin-packages.properties file in other portlet which is going to use the service.

required-deployment-contexts=your-portlet

you dont need persistence folder in other portlet, create custom sql in your main portlet containing the service and you would able to access the same in another portlet as your are sharing the service jar.
thumbnail
John Voltaire Maximo, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Regular Member Postagens: 106 Data de Entrada: 19/06/15 Postagens Recentes
I'm doing the last thing you said,,, I am doing all the custom querying on the first portlet,,, after doing all that I will build the service again and import the service jar on the second portlet,,,
Will that work sir? what do you think
thumbnail
Harish Kumar, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
yes that should work
thumbnail
David H Nebinger, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
No, it will not work.

When the two sides each declare a dependency in liferay-plugin-package.properties, the classes are still loaded by two separate class loaders and therefore will not go across the class loader boundary.

You could make the jar global but that is honestly a PITA.
thumbnail
John Voltaire Maximo, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Regular Member Postagens: 106 Data de Entrada: 19/06/15 Postagens Recentes
then how should this work sir? I just copied the service jar... then should I just build the same service.xml on both of them, to be able to create my custom-sql?
anyway I'll just try making the jar global..
thumbnail
Meera Prince, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Liferay Legend Postagens: 1111 Data de Entrada: 08/02/11 Postagens Recentes
HI
Liferay scalars concept.

try this way.
http://www.liferaysavvy.com/2014/06/scalars-in-liferay-custom-sqlcustom-sql.html


Regards,
Meera Prince
thumbnail
David H Nebinger, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
Snap, somehow I thought it was third party jar of classes, so let me roll back and reset...

Using SB you have two types of projects: a service provider and a service consumer (sometimes multiple consumers).

The service provider has the service.xml file and implements ALL of the service stuff. Methods created in the XxxLocalServiceImpl classes will get added to the XxxLocalServiceUtil class in the service jar for consumers to invoke.

Service consumers use the API defined in the service jar to access the service layer.

SB works if you maintain this separation in a clean and consistent manner. So when you say "I need custom SQL in both the provider and the consumer", I would say that you are trying to put the custom SQL in the wrong place. Instead you put your custom SQL only in the service provider and the consumers just invoke methods using the service jar.

The service consumer should only ever be using the service jar APIs. When I'm using SB, I don't even let my service consumers do DQ invocations because I think the service provider is the best place to define the service API (well, that plus it resolves all kinds of class loader issues emoticon).
thumbnail
Harish Kumar, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
John Voltaire Maximo:
I'm doing the last thing you said,,, I am doing all the custom querying on the first portlet,,, after doing all that I will build the service again and import the service jar on the second portlet,,,
Will that work sir? what do you think



It will work for sure. At least give it a try before posting.
thumbnail
John Voltaire Maximo, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Regular Member Postagens: 106 Data de Entrada: 19/06/15 Postagens Recentes
emoticon
thumbnail
John Voltaire Maximo, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Regular Member Postagens: 106 Data de Entrada: 19/06/15 Postagens Recentes
Harish Kumar

Hey sir, I did what you told me, however I can't access the FinderImpl class on the second portlet..
I tried to query on the first portlet and it's working fine,, but not when I try to use the query on the second portlet
How do I do this?
thumbnail
David H Nebinger, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
Finders are never directly exposed via the service jar. Use my approach instead.
thumbnail
John Voltaire Maximo, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Regular Member Postagens: 106 Data de Entrada: 19/06/15 Postagens Recentes
I don't want to sound offensive, but I don't really get your suggestion sir David..
can you help me understand in a noob's language hahaha emoticon

Thanks for the explanation, problem is I can't really find the suggestion in it emoticon
thumbnail
John Voltaire Maximo, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Regular Member Postagens: 106 Data de Entrada: 19/06/15 Postagens Recentes
After studying a bit about this, now I know how to resolve it,,,
as sir David and Harish said, I could put the jar into the global classpath
even though it's really not a good way to solve my problem I did it,

Thanks guys
thumbnail
Meera Prince, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Liferay Legend Postagens: 1111 Data de Entrada: 08/02/11 Postagens Recentes
thumbnail
John Voltaire Maximo, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Regular Member Postagens: 106 Data de Entrada: 19/06/15 Postagens Recentes
I also looked into that Prince sir, but I already made it global so I'm satisfied,,, though your solution works as another approach
thumbnail
Meera Prince, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Liferay Legend Postagens: 1111 Data de Entrada: 08/02/11 Postagens Recentes
HI
Thank you in that post if see comments we talked about global class path approach and as you said we need more attention when we share service layer between two plugin portlets.

Regards,
Meera Prince
thumbnail
Harish Kumar, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
As David suggested FinderImpl is never exposed directly you should access your api via XXXLocalServiceUtil. Does not matter you want to share the service jar at global level or among plugins , you will be able to access the api.

BTW good to know you issue is fixed now.
thumbnail
John Voltaire Maximo, modificado 8 Anos atrás.

RE: creating finderImpl if model is on imported jars (service-builder)

Regular Member Postagens: 106 Data de Entrada: 19/06/15 Postagens Recentes
Harish thanks, I made the jar global which isn't good I think...
that means I can access my jar in every portlet I make in the future... haha but I'm glad I'm not stuck....