Accessing Tables Using Service Builder

Vivek Mehta, modified 6 Years ago. Junior Member Posts: 48 Join Date: 4/7/19 Recent Posts
Hi all !I made a table using service builder. Now in that current project i can easily access the table by importing   "package.model.impl" and "package.service" packages. But I am having trouble when i need to access the table from another project. Please help me how can i access these tables from another projects !! One way was by using jdbc connection and then hitting sql queries. But i want to know how can i do this using service builder !!
Venky B, modified 6 Years ago. New Member Posts: 6 Join Date: 10/30/14 Recent Posts
HI Vivek,
Try to use LocalServiceUtil of another project in your new. You can do this by using JAR of other project into your current project.

Venky
thumbnail
Olaf Kock, modified 6 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Vivek Mehta:

Hi all !I made a table using service builder. Now in that current project i can easily access the table by importing   "package.model.impl" and "package.service" packages. But I am having trouble when i need to access the table from another project. Please help me how can i access these tables from another projects !! One way was by using jdbc connection and then hitting sql queries. But i want to know how can i do this using service builder !!
I'm assuming you're on 6.2, as you've just asked another question about that version (please add the version in every question):
If you declare a dependency on that other service-builder-project in liferay-plugin-package.properties (by using required-deployment-contexts=your-other-plugin), that project's service.jar will be available to your own plugin, and you can use the services from that other project. No need for JDBC access to those tables (which would be breaking the encapsulation and introduce all kinds of caching inconsistencies anyway)
Vivek Mehta, modified 6 Years ago. Junior Member Posts: 48 Join Date: 4/7/19 Recent Posts
Thanks Olaf,
I implemented what you said. But still i am facing difficulty in accessing the table. Before in old project I  used  " oldproject  p1  = new oldprojectImpl();  "   and then accessed the tables by using p1.setName("vivek")  and p1.getName() .  But I am not able able to import this oldprojectImpl  package in new project. Though i am able to import the model, service and local service util packages   but i am not getting how to use these in accessing the table. Please help ..
thumbnail
Christoph Rabel, modified 6 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
You should have a class "oldprojectLocalService" available. That class contains various create/read/update/delete methods for your entities.