Foros de discusión

ServiceBuilder - Issue with one-to-many relationship

Duc Duc, modificado hace 12 años.

ServiceBuilder - Issue with one-to-many relationship

New Member Mensajes: 3 Fecha de incorporación: 1/11/11 Mensajes recientes
I got problem with ServiceBuilder

This is my service.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">

<service-builder package-path="stu.bookstore">
<author>Duc Anh</author>
<namespace>stu_bookstore</namespace>
<entity name="Catalog" local-service="true" remote-service="false">
<column name="catalogId" type="long" primary="true"></column>
<column name="catalogName" type="String"></column>

<column name="books" type="Collection" entity="Book" mapping-key="catalogId"></column>

</entity>

<entity name="Book" local-service="true" remote-service="false">
<column name="bookId" type="long" primary="true"></column>
<column name="title" type="String"></column>
<column name="price" type="double"></column>
<column name="quantity" type="int"></column>

<column name="catalogId" type="long"></column>

</entity>
</service-builder>

But I cannot find any results by defining this line: <column name="books" type="Collection" entity="Book" mapping-key="catalogId"></column>

There are no setters or getters or attributes in the Catalog-Classes or at least errors or warnings. The line is completely ignored.

What are we doing wrong?
thumbnail
Hitesh Methani, modificado hace 12 años.

RE: ServiceBuilder - Issue with one-to-many relationship

Regular Member Mensajes: 171 Fecha de incorporación: 24/06/10 Mensajes recientes
+1, same issue even I am facing.

Regards,
Hitesh Methani
Peter Hellstrand, modificado hace 12 años.

RE: ServiceBuilder - Issue with one-to-many relationship

Regular Member Mensajes: 166 Fecha de incorporación: 30/11/11 Mensajes recientes
Did any of you solve this? I am having the same problem.
Mohamed Rizwanuzaman, modificado hace 12 años.

RE: ServiceBuilder - Issue with one-to-many relationship

New Member Mensajes: 20 Fecha de incorporación: 17/12/09 Mensajes recientes
Hi Duc,

I have same problem while dealing with one to many relationship in service builder. Its solved for me.
I had the followed the below steps in LR-6.1
After you mentioned the mapping-key in service builder ,do ant-build-service,
It will a generate a method in persistence class of your entity related to your mapping-key.
Using the persistence method you can write the getters method in your implementation class and do ant build service before deploying it.
In your case:
you have to write a method to get the list of book associate with catalog id. Correct me if i wrong

Here is my example in localserviceimpl class for my scenario. it will list out the all employees associate to the department.

public class DepartmentLocalServiceImpl extends DepartmentLocalServiceBaseImpl {

public List<Employee> getDepartmentEmployees(long departmentId) throws SystemException, Exception {
List<Employee> employeeList = departmentPersistence.getEmployees(departmentId);

return employeeList;
}
}


now then you can access the util class in your action file.

Example to get list of employees related to department.

List<Employee> employeeList = DepartmentLocalServiceUtil.getDepartmentEmployees(departmentId);

Hope this step will give you some idea.
you can find my service builder in attachements
Regards,
Rizwan

Archivos adjuntos: