Creating liferay service builder without configuring any database
Asked Answered
B

4

7

Is it possible to create liferay service builder without any configuring any database tables in service.xml file.

Actually purpose here is to create a service layer using liferay service builder. And there is no database interaction directly in this service layer.

Bothy answered 5/5, 2016 at 2:19 Comment(0)
D
5

Yes, and it's quite simple. While you still need an entity (which provides the name for your service) you can leave this entity definition empty.

This will create the service (local or remote, as configured in the entity) but no model, no persistence and no database table.

One of the situations where this comes in really handy is when you want to add another method to an existing service (which you can't) - you just create a new service with your custom methods and delegate to the original service.

Dingdong answered 5/5, 2016 at 6:35 Comment(1)
one concern is that in such cases we can not have our own class as a return type of newly defined methods in service impl classes. Like in a previous scenario i used JSONArray, JSONObject or any class which is present in liferay bundle. So that when you do 'Build-Services' it get that class in service project also. But if you take return type as class 'Student' (defined in portlet-project), but it's not visible to service project. Is there any other way to do it ?Tadeas
N
0

Its highly recommended that If you're creating Service.xml then at least one entity should be there. Otherwise no need to add that configuration.

Notability answered 5/5, 2016 at 5:53 Comment(1)
This answer is almost correct. Just the opening "No" is wrong. You'll need an entity, but it doesn't need persistence.Dingdong
S
0

I agree with @Olaf Kock answare in which say that it is possible have an empty model with service builder. Furthermore have an empty entity you can benefit of have the same transactional context of your portal and benefit of cluster managing and benefit of a complete integration with liferay portal.

If you have the same transactional enviroment of the portal you can image of create a service that agregate native liferay service and you get the assurance that the transactional context is the same of the portal.

I hop that this reflection can add value.

Subsist answered 5/5, 2016 at 8:35 Comment(0)
B
0

Able to create service builder without real entities.

As provided in the link it is possible to create service builder without entities.

Also discussed more in detail in this forum

Hope it helps some one. Thanks

Bothy answered 4/4, 2018 at 6:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.