I want to delete specific record using Field Name
Table : Dummy Entity
- Field Id
Field Name
public void deleteLocation(req, res){ String getLocationName = request.getParameter("locationName"); Location locationToDelete = new LocationImpl(); locationToDelete.setLocationName(getLocationName); LocationLocalServiceUtil.deleteLocation(locationToDelete); }
It's not showing me any error but the record doesn't get deleted. Please hep me out.
The simplest way to achieve this is to add
<finder>
node for that specific field inservice.xml
, as following (sayingLocation
is your entity name,name
is your field name andName
is the name of finder entry inservice.xml
) and build service:On successful build, it will create CRUD operations in your service based on that column. Now you can find following methods in your
LocationUtil.java
:Create following (new) method in
LocationLocalServiceImpl.java
:Again, on building service, this method will be available for use in your action class from
LocationLocalServiceUtil.java
, where you can call it like:That's it, you have added custom finder method to your service.