I want to write a dynamic query which will delete values from a row those will be supplied, i.e a row contains lets say 6 elements i want to delete only 3 of them.How i can achieve that using liferay dynamic query.I am creating a book database and and this my table,I have added picture here.
Now i want to delete description and authorname from second row lets say.How i can do that???Previously i was doing by this
long bookId = ParamUtil.getLong(actionRequest, "bookId");
BookLocalServiceUtil.deleteBook(bookId);
SessionMessages.add(actionRequest, "deleted-book");
_log.info("#################Book Deleted Successfully#########################");
Lets assume that bookName,description etc i can supply inside the delete method.
The only and best way to perform what you want to is to update your entity. For doing so, you have to first retrieve the entity using a
DynamicQuery
and then to update it using the persistence layer.If you have the bookId and it is your only criterion, you can also use the persistence layer directly to retrieve a bean of your entity.
For your purpose, I think the following is a good solution, in your
BookLocalServiceImpl
:Then in your controller simply call
BookLocalServiceUtil.updateDescription("")
and voila, you just cleared the description.