Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Service Builder Persistance Impl Errors in case of TableMapper
We are working on migration of service builder code from 6.2 to DXP/7.0 using IDE.
Now, in case of Liferay 6.2 we have used "mapping-table" feature for few entities. When trying to use similar entities in Liferay 7 IDE, we are getting errors in *PersistanceImpl of that entity.
Below is my build.gradle:-
dependencies {
compileOnly group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "+"
compileOnly group: "com.liferay", name: "com.liferay.osgi.util", version: "+"
compileOnly group: "com.liferay", name: "com.liferay.portal.spring.extender", version: "+"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "+"
compileOnly project(":modules:sample-service:sample-service-api")
}
buildService {
apiDir = "../sample-service-api/src/main/java"
}
group = "sample.service"
Below is my entity definition:-
<entity name="Employee" remote-service="false" local-service="true">
<column name="employeeId" type="long" primary="true"></column>
<column name="name" type="String"></column>
<column name="deptId" type="Collection" entity="Department" mapping-table="Employee_department" />
</entity>
<entity name="Department" remote-service="false" local-service="true">
<column name="deptId" type="long" primary="true"></column>
<column name="name" type="String"></column>
<column name="employeeId" type="Collection" entity="Employee" mapping-table="Employee_department" />
</entity>
Below is the error in DepartmentPersistanceImpl (Similar case for EmployeePersistanceImpl):-
The method getCompanyId() is undefined for the type Department
Please find Attached screenshot of the same.
Appreciate your response in this matter.
Thanks and Regards,
Aliasgar Pratapgarhwala
can you try to add the column
<column name="companyId" type="long" />
into your both two entities?
Yes it works, Thank you for your response.
Just to add some advice here, based on my own experience.
When the Service Builder "template" service.xml file is generated there is a section with companyId, groupId, userId, userName, createDate, modifiedDate. I would recommend that you always leave those fields and complete them when creating records. You may not need them now, but they provide a certain degree of future proofing in the even that you need to reuse this same entity across multiple sites or portal instances -- it allows you to properly scope data for different properties in the same table.
Since 7.0 version, companyId column was added to all Liferay tables in order to allow configuring data partitioning at database level by instances (companyId).
So perhaps there is some servicebuilder code that takes for granted every entity has companyId field.
Powered by Liferay™