Posts

Showing posts from January, 2017

Running Custom SQL

In Liferay by default , ServiceBuilder generated LocalServiceBaseImpl class contains a method call runSQL. We can use that method to execute our CustomSQL Query of that Entity. If we want to execute the customSQL of Blogs Entity we can use that method by call in the localserviceImpl. Example: 1. I have a table call " Employee " and i want to execute the Employee table  related custom SQL 2. So i have written a custom method in EmployeeLocalServiceImpl  as below and calling runSQL method  public void executeCustomQuery(String cusQuery) throws SystemException{ super.runSQL(query); } 3. Build the service and call the sql query as  EmployeeLocalServiceUtil.executeCustomQuery(' update table Employee set EmpName = 'Liferay' where EmpId = 2 '); So here it is , We can Execute the SQL queries