I have a table named xyz with various records
The service.xml has the below mentioned entry
<entity name="xyz" local-service="true" remote-service="true" cache-enabled="true" json-enabled="true">
<column name="sno" type="int" primary="true" id-type="identity"></column>
<column name="name" type="String"></column>
<column name="address" type="String"></column>
<column name="userid" type="int"></column>
<finder return-type="Collection" name="userid">
<finder-column name="userid"></finder-column>
</finder>
</entity>
Now I want to delete all the user having userid 10
Using service builder we can do as follow
List<xyz> xyzList = XyzLocalServiceUtil.findbyuserid(10);
if(xyzList!=null && !xyzList.isEmpty()){
for (xyz xy : xyzList) {
xyzListLocalServiceUtil.deleteXyz(xy.getSno());
}
}
But I want to delete all the rows in one go like by executing the below mentioned query
delete from xyz where userid =10;
what would be the liferay service builder equivalent of this?
I am using liferay-6.2-ce-ga3
When you declare a finder in the service.xml, the service builder procedure generates also the delete method based on the same finder.
Search and you will find a method as XyzPersistence.deletebyuserid()
You can build a new method in the XyzLocalServiceImpl to call the delete in persistence layer, ant service-builder
, and you'll have the massive delete in the localservice layer.