Foros de discusión

Performing Crud Operations in Liferay 7

thumbnail
venky yuvan, modificado hace 6 años.

Performing Crud Operations in Liferay 7

New Member Mensajes: 8 Fecha de incorporación: 21/04/17 Mensajes recientes
Performing Crud operations in liferay 7

init.jsp :

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %><%@
taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %><%@
taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %><%@
taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

<%@page import="com.liferay.portal.kernel.util.ParamUtil"%>

<%@page import="java.util.List" %>
<%@page import="com.liferay.portal.kernel.util.ListUtil" %>

<liferay-theme:defineobjects />

<portlet:defineobjects />


addEmp.jsp :

&lt;%@ include file="/init.jsp" %&gt;
&lt;%@page import="java.util.List"%&gt;
&lt;%@page import="com.emp.service.EmpDetailsLocalServiceUtil"%&gt;
&lt;%@ include file="/init.jsp" %&gt;

&lt;%@page import="com.emp.model.EmpDetails" %&gt;
&lt;%@page import="com.emp.model.EmpDetailsModel" %&gt;

&lt;%@page import="java.util.LinkedList" %&gt;
&lt;%
	List<empdetails> dd= EmpDetailsLocalServiceUtil.getEmpDetailses(-1, -1);
	
%&gt;

<h1> employee  form</h1>

<portlet:actionurl name="addEmploye" var="addEmployeURL"></portlet:actionurl>
<aui:form action="<%=addEmployeURL %>" method="post">
	<aui:input name="EmployeID" label="EmployeID" type="hidden">
	</aui:input>
	<aui:input name="EmplyeName" label="EmplyeName" type="text">
		<aui:validator name="required" />
		<aui:validator name="alpha" />
	</aui:input>
	<aui:input name="Age" label="Age" type="text">
		 <aui:validator name="digits" />
		 <aui:validator name="range">
		 	[8,50]
		</aui:validator>
	</aui:input>
	<aui:select name="Qualification" label="Qualification">
		<aui:option>--Select--</aui:option>
		<aui:option name="Qualification" value="B-tech">B-tech</aui:option>
		<aui:option name="Qualification" value="B.com">B.com</aui:option>
		<aui:option name="Qualification" value="Mca">Mca</aui:option>
		<aui:option name="Qualification" value="M-tech">M-tech</aui:option>
		<aui:option name="Qualification" value="MBA">MBA</aui:option>
	</aui:select>
	<aui:input name="Salary" label="Salary" type="text">
		 <aui:validator name="digits" />
	</aui:input>
	<aui:button name="Save" type="Submit" value="Save"></aui:button>
</aui:form></empdetails>

Here "addEmploye " is the action method name so its hiting java class in (EX:EmployePortlet.java)

public void addEmploye(ActionRequest actionRequest, ActionResponse acResponse) throws PortalException {
		_log.info("am inside of the method");
		Long employeid = ParamUtil.getLong(actionRequest, "EmployeID");
		String emplyename = ParamUtil.getString(actionRequest, "EmplyeName");
		int age = ParamUtil.getInteger(actionRequest, "Age");
		String[] qualification = ParamUtil.getParameterValues(actionRequest, "Qualification");
		String qualifications = Arrays.toString(qualification);
		Long salary = ParamUtil.getLong(actionRequest, "Salary");
		_log.info("employeid=="+employeid);
		_log.info("Qualifications=="+qualifications);
		_log.info("Salary=="+salary);
		_log.info("EmplyeName=="+emplyename);
		_log.info("Age=="+age);
		_log.info("Qualification=="+qualification);
	
		EmpDetailsLocalServiceUtil.empDetails(employeid,emplyename,age,qualifications,salary);
	}


For creating Crud operations we have to create Service builder then

service.xml :

<entity local-service="true" name="EmpDetails" remote-service="false" uuid="true">

		<!-- PK fields -->

		<column name="employeid" primary="true" type="long" />
		<column name="emplyename" type="String" />

		<column name="age" type="int" />
		<column name="qualification" type="String" />
		<column name="salary" type="long" />
		<column name="band" type="String" />
	</entity>


am performing add operation in LocalServiceImpl.java(EX:EmpDetailsLocalServiceImpl.java) by using "empDetails"

public EmpDetails empDetails(Long employeid,String emplyename,int age,String qualifications,Long salary)throws SystemException {
		EmpDetails empDetails = new EmpDetailsImpl();
		_log.info("am inside of the  EmpDetailsLocalServiceImpl method");
		_log.info("salary =="+salary);
		_log.info("employeeid=="+employeid);
		employeid = 0l;
		employeid = CounterLocalServiceUtil.increment();
		empDetails.setEmployeid(employeid);
		empDetails.setEmplyename(emplyename);
		empDetails.setAge(age);
		empDetails.setQualification(qualifications);
		empDetails.setSalary(salary);
		
		if(salary &gt;= 150000 &amp;&amp; salary &lt;= 350000  ){
			System.out.println("B1");
			empDetails.setBand("B1");
		}
		if (salary &gt;= 360000 &amp;&amp; salary &lt;= 550000 ) {
			System.out.println("B2");
			empDetails.setBand("B2");
		}
		if (salary &gt;= 560000 &amp;&amp; salary &lt;= 750000 ) {
			System.out.println("B3");
			empDetails.setBand("B3");
		}
		else if (salary &gt;= 750000) {
			System.out.println("B4");
			empDetails.setBand("B4");
		}
		empDetails = addEmpDetails(empDetails);
		return empDetails;
}

After complition of these method we can add our emp details in to database.Here am getting all employe details by using search container there only am performing Update and Delete operations

view.jsp:

&lt;%@ include file="/init.jsp" %&gt;
&lt;%@page import="javax.portlet.RenderResponse"%&gt;
&lt;%@page import="javax.portlet.PortletURL"%&gt;
&lt;%@page import="java.util.List"%&gt;
&lt;%@page import="com.emp.service.EmpDetailsLocalServiceUtil"%&gt;

&lt;%@page import="com.liferay.portal.kernel.util.ListUtil"%&gt;
&lt;%@page import="com.emp.model.EmpDetails" %&gt;
&lt;%@page import="com.emp.model.EmpDetailsModel" %&gt;

&lt;%@page import="java.util.LinkedList" %&gt;

&lt;%
	List<empdetails> dd= EmpDetailsLocalServiceUtil.getEmpDetailses(-1, -1);
	
%&gt;

<portlet:renderurl var="listURL">
	<portlet:param name="mvcPath" value="/addEmp.jsp" />
</portlet:renderurl>
<a href="<%=listURL%>"><button>AddEmp</button> </a>

<liferay-ui:search-container delta="10" emptyresultsmessage="NoPage">	
	<liferay-ui:search-container-results results="<%=ListUtil.subList(dd, searchContainer.getStart(), searchContainer.getEnd()) %>" />
	<liferay-ui:search-container-row classname="EmpDetails" modelvar="Emp" keyproperty="employeid">
	
	<portlet:renderurl var="updateURL">
	        <portlet:param name="jspPage" value="/update.jsp" />
	         <portlet:param name="employeid" value="${Emp.employeid}" />
	</portlet:renderurl>
	<portlet:actionurl name="EmpDelete" var="DeleteURL">
			 <portlet:param name="employeid" value="${Emp.employeid}" />
	</portlet:actionurl>
	
		<liferay-ui:search-container-column-text name="Id" property="employeid" />
		<liferay-ui:search-container-column-text name="Name" property="emplyename" />
		<liferay-ui:search-container-column-text name="Age" property="age" />
		<liferay-ui:search-container-column-text name="Qualifiaction" property="qualification" />
		<liferay-ui:search-container-column-text name="Salary" property="salary" />
		<liferay-ui:search-container-column-text name="Band" property="band" />
		<liferay-ui:search-container-column-text name="Update" href="${updateURL}" value="Update">
		</liferay-ui:search-container-column-text>
		<liferay-ui:search-container-column-text name="Delete" href="${DeleteURL}" value="Delete">
		</liferay-ui:search-container-column-text>
	</liferay-ui:search-container-row>
	<liferay-ui:search-iterator searchContainer="<%=searchContainer%>" />
</liferay-ui:search-container></empdetails>


update.jsp:

&lt;%@ include file="/init.jsp" %&gt;
&lt;%@page import="com.liferay.portal.kernel.util.ParamUtil"%&gt;
&lt;%@page import="com.emp.model.impl.EmpDetailsImpl"%&gt;
&lt;%@page import="com.emp.service.EmpDetailsLocalServiceUtil"%&gt;

&lt;%@page import="com.liferay.portal.kernel.util.ListUtil"%&gt;
&lt;%@page import="com.emp.model.EmpDetails" %&gt;
&lt;%@page import="com.emp.model.EmpDetailsModel" %&gt;
&lt;%@page import="com.liferay.portal.kernel.util.ParamUtil"%&gt;

&lt;%@page import="java.util.LinkedList" %&gt;
&lt;%@page import="java.util.List"%&gt;
&lt;%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %&gt;
&lt;%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %&gt;
&lt;%
	List<empdetails> dd= EmpDetailsLocalServiceUtil.getEmpDetailses(-1, -1);
	long employeid = ParamUtil.getLong(request, "employeid");
	EmpDetails empDetails = EmpDetailsLocalServiceUtil.getEmpDetails(employeid);
	if(employeid &gt; 0l){
		empDetails = EmpDetailsLocalServiceUtil.fetchEmpDetails(employeid);
	} 
	System.out.println("name=="+empDetails.getEmplyename());
	System.out.println("Qualification=="+empDetails.getQualification());
%&gt;

<h1> employee  form</h1>

<portlet:actionurl name="updateEmploye" var="addEmployeURL"></portlet:actionurl>
<aui:form action="<%=addEmployeURL %>" method="post">
	<aui:input name="EmployeID" label="EmployeID" type="hidden" value="<%=empDetails.getEmployeid() %>" />
	<aui:input name="EmplyeName" label="EmplyeName" type="text" value="<%=empDetails.getEmplyename() %>">
		<aui:validator name="required" />
		<aui:validator name="alpha" />
	</aui:input>
	<aui:input name="Age" label="Age" type="text" value="<%=empDetails.getAge() %>">
		 <aui:validator name="digits" />
		 <aui:validator name="range">
		 	[8,50]
		</aui:validator>
	</aui:input>
	<aui:select name="Qualification" label="Qualification">
		<aui:option name="Qualification">&lt;%=empDetails.getQualification() %&gt; </aui:option>
		<aui:option name="Qualification" value="B-tech">B-tech</aui:option>
		<aui:option name="Qualification" value="B.com">B.com</aui:option>
		<aui:option name="Qualification" value="Mca">Mca</aui:option>
		<aui:option name="Qualification" value="M-tech">M-tech</aui:option>
		<aui:option name="Qualification" value="Mba">MBA</aui:option>
	</aui:select>
	<aui:input name="Salary" label="Salary" type="text" value="<%=empDetails.getSalary() %>">
		 <aui:validator name="digits" />
	</aui:input>
	<aui:button name="Save" type="Submit" value="Update"></aui:button>
</aui:form></empdetails>


Here "updateEmploye " is the action method name so its hiting java class in (EX:EmployePortlet.java)

public void updateEmploye(ActionRequest actionRequest, ActionResponse actionResponse) {
		_log.info("am inside of the empUpdate method");
		Long employeid = ParamUtil.getLong(actionRequest, "EmployeID");
		String emplyename = ParamUtil.getString(actionRequest, "EmplyeName");
		int age = ParamUtil.getInteger(actionRequest, "Age");
		String[] qualification = ParamUtil.getParameterValues(actionRequest, "Qualification");
		String qualifications = Arrays.toString(qualification);
		Long salary = ParamUtil.getLong(actionRequest, "Salary");
		_log.info("employeid=="+employeid);
		_log.info("emplyename=="+emplyename);
		_log.info("age=="+age);
		_log.info("qualifications=="+qualifications);
		_log.info("Salary=="+salary);
		EmpDetailsLocalServiceUtil.updateEmploye(employeid,emplyename,age,qualifications,salary);
	}


am performing Update operation in LocalServiceImpl.java(EX:EmpDetailsLocalServiceImpl.java) by using "updateEmploye"

public  EmpDetails updateEmploye(Long employeid,String emplyename,int age,String qualifications,Long salary) {
		_log.info("employeid=="+employeid);
		EmpDetails empDetails = new EmpDetailsImpl();
		if(employeid &gt; 0l){
				empDetails = EmpDetailsLocalServiceUtil.fetchEmpDetails(employeid);
		}
		empDetails.setEmployeid(employeid);
		empDetails.setEmplyename(emplyename);
		empDetails.setAge(age);
		empDetails.setQualification(qualifications);
		empDetails.setSalary(salary);
		if(employeid &gt; 0l){
			empDetails = updateEmpDetails(empDetails);
		}
		return empDetails;
		
	}


For deleting am creating method in EmployPortlet.java only (we can do in your impl.java aslo)

public void  EmpDelete(ActionRequest actionRequest,ActionResponse acResponse) throws PortalException {
		_log.info("am inside of the delete method");
		long employeid = ParamUtil.getLong(actionRequest, "employeid");
		_log.info("empid=="+employeid);
		EmpDetailsLocalServiceUtil.deleteEmpDetails(employeid);
		SessionMessages.add(actionRequest, "success");
	}


Thank You
Venky(RjYuvan)
thumbnail
David H Nebinger, modificado hace 6 años.

RE: Performing Crud Operations in Liferay 7

Liferay Legend Mensajes: 14918 Fecha de incorporación: 2/09/06 Mensajes recientes
Thanks for sharing. I did want to point out some things that would make your code better and more consistent with Liferay's recommended approaches...

venky yuvan:
addEmp.jsp :

&lt;%@page import="com.emp.service.EmpDetailsLocalServiceUtil"%&gt;



Well, no, this is the first big mistake. The Util classes should not be used in any new code, they are there primarily to serve legacy code.

Instead, you should be injecting a reference to EmpDetailsLocalService in your portlet class using the OSGi @Reference annotation. Then you override the render() method to add a render attribute with the EmpDetailsLocalService reference. This puts the service reference into the context that your JSP can access and use.

Injecting Service Into Portlet Class: https://github.com/dnebing/filesystem-access/blob/master/modules/apps/filesystem-access-web/src/main/java/com/liferay/filesystemaccess/portlet/FilesystemAccessPortlet.java#L68-L73
Overriding render() to inject attribute: https://github.com/dnebing/filesystem-access/blob/master/modules/apps/filesystem-access-web/src/main/java/com/liferay/filesystemaccess/portlet/FilesystemAccessPortlet.java#L53-L62
Extracting Service in init.jsp: https://github.com/dnebing/filesystem-access/blob/master/modules/apps/filesystem-access-web/src/main/resources/META-INF/resources/init.jsp#L65

&lt;%
	List<empdetails> dd= EmpDetailsLocalServiceUtil.getEmpDetailses(-1, -1);
%&gt;</empdetails>


This code would change to:

&lt;%
	List<empdetails> dd= _empDetailsLocalService.getEmpDetailses(-1, -1);
%&gt;</empdetails>


Just change the _empDetailsLocalService to whatever name you use for the variable.

<portlet:actionurl name="addEmploye" var="addEmployeURL"></portlet:actionurl>

Here "addEmploye " is the action method name so its hiting java class in (EX:EmployePortlet.java)


This is wrong then too. Follow the Liferay way to define an action URL similar to https://github.com/dnebing/filesystem-access/blob/master/modules/apps/filesystem-access-web/src/main/resources/META-INF/resources/add_file_folder.jsp#L25-L27. Once you have the right URL defined for the form, you implement an action command class mapped to the action path: https://github.com/dnebing/filesystem-access/blob/master/modules/apps/filesystem-access-web/src/main/java/com/liferay/filesystemaccess/portlet/action/AddFileFolderMVCActionCommand.java#L29-L38.

Separating these is important as it determines what future upgrade/override paths are available. In your implementation, we can't override jack. You've embedded the action handler directly into the portlet and therefore cannot affect any change in the deployed artifact.

If you separate it out, though, someone can implement their own action command with a higher service ranking to override your implementation, so it is easier to override or extend your implementation.

public void addEmploye(ActionRequest actionRequest, ActionResponse acResponse) throws PortalException {
	EmpDetailsLocalServiceUtil.empDetails(employeeid,emplyename,age,qualifications,salary);
}


And again, the LocalServiceUtil classes should be avoided. Instead the action command will also have an @Reference to inject the service reference and will use it in the command handler. https://github.com/dnebing/filesystem-access/blob/master/modules/apps/filesystem-access-web/src/main/java/com/liferay/filesystemaccess/portlet/action/AddFileFolderMVCActionCommand.java#L126-L131 and https://github.com/dnebing/filesystem-access/blob/master/modules/apps/filesystem-access-web/src/main/java/com/liferay/filesystemaccess/portlet/action/AddFileFolderMVCActionCommand.java#L107-L108.

Also your method name prevents the appropriate wrapping of a transaction around the method - stick with prefixes like "add", "save", or "update" for your method name as Liferay will always wrap the method call in a transaction for appropriate rollback handling. Instead of a method named "empDetails()", call it "addEmpDetails()".


For creating Crud operations we have to create Service builder then

service.xml :

<entity local-service="true" name="EmpDetails" remote-service="false" uuid="true">

		<!-- PK fields -->

		<column name="employeid" primary="true" type="long" /></entity>


Pay attention to spelling when you are creating your service.xml file. It is hard to rework your entire service layer when someone notices a spelling error in employeeId. Take your time and get spelling right the first time to save yourself and your team a lot of rework or embarrassment later on.

am performing add operation in LocalServiceImpl.java(EX:EmpDetailsLocalServiceImpl.java) by using "empDetails"

public EmpDetails empDetails(Long employeeid,String emplyename,int age,String qualifications,Long salary)throws SystemException {
		EmpDetails empDetails = new EmpDetailsImpl();
		_log.info("am inside of the  EmpDetailsLocalServiceImpl method");
		_log.info("salary =="+salary);
		_log.info("employeeid=="+employeeid);
		employeeid = 0l;
		employeeid = CounterLocalServiceUtil.increment();
		empDetails.setEmployeid(employeeid);


This is totally wrong. You should never be doing "new" anything. Instead, all of this can be summarized down to the correct line:

EmpDetails empDetails = createEmpDetails(counterLocalService.increment(EmpDetails.class.getName());


This code has the following advantages:

  • It hides the concrete class so when folks deploy an EmpDetails model wrapper your code still works.
  • It uses the already injected CounterLocalService instance and avoids the use of the LocalServiceUtil classes.
  • It uses your specific class for the increment() call so the counters assigned will be tied directly to your entity rather than some generic counter value.


		if(salary &gt;= 150000 &amp;&amp; salary &lt;= 350000  ){
			System.out.println("B1");
			empDetails.setBand("B1");
		}


Never, ever, ever use System.out() or System.err(). There is no guarantee where these messages will go or if they will be logged at all. They will always be executed even in prod environments where this kind of thing can leak details.

Instead, take the time to create an instance of com.liferay.portal.kernel.Log and use it appropriately. Wrap messages with the "log.isDebugEnabled()" check to only issue debug statements when enabled, save these things from appearing in production. https://github.com/dnebing/filesystem-access/blob/master/modules/apps/filesystem-access-web/src/main/java/com/liferay/filesystemaccess/portlet/action/AddFileFolderMVCActionCommand.java#L107-L108


view.jsp:

&lt;%
	List<empdetails> dd= EmpDetailsLocalServiceUtil.getEmpDetailses(-1, -1);
%&gt;</empdetails>


So first we drop the use of the LocalServiceUtil class since we already have it injected and know how to access it.

A smaller issue here is the use of the -1. This has no meaning to anyone who does not understand what it represents in Liferay. Two options are:
  • Replace the -1 with QueryUtil.ALL_POS, this at least has better meaning in context.
  • The better option is to create a getAllEmpDetails() method in your EmpDetailsLocalServiceImpl class that encapsulates and hides the use of the constant. That way the code is completely clear that you are fetching all emp detail records without exposing implementation details.



update.jsp:

&lt;%@ include file="/init.jsp" %&gt;
&lt;%@page import="com.liferay.portal.kernel.util.ParamUtil"%&gt;
&lt;%@page import="com.emp.model.impl.EmpDetailsImpl"%&gt;
&lt;%@page import="com.emp.service.EmpDetailsLocalServiceUtil"%&gt;

&lt;%@page import="com.liferay.portal.kernel.util.ListUtil"%&gt;
&lt;%@page import="com.emp.model.EmpDetails" %&gt;
&lt;%@page import="com.emp.model.EmpDetailsModel" %&gt;
&lt;%@page import="com.liferay.portal.kernel.util.ParamUtil"%&gt;

&lt;%@page import="java.util.LinkedList" %&gt;
&lt;%@page import="java.util.List"%&gt;
&lt;%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %&gt;
&lt;%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %&gt;


Why aren't all of these in your init.jsp? The only ones that should be in the direct JSP file are the ones that are unique to this file from other JSPs in the portlet.

&lt;%
	List<empdetails> dd= EmpDetailsLocalServiceUtil.getEmpDetailses(-1, -1);
</empdetails>


Why does the update need to pull all of the details? I don't think it needs to, this seems to be a copy n paste error.

	System.out.println("name=="+empDetails.getEmplyename());
	System.out.println("Qualification=="+empDetails.getQualification());
%&gt;


Never, ever, ever use System.out, even in a JSP file. Instead you can create a com.liferay.portal.kernel.Log instance and use it in your JSP files too. https://github.com/dnebing/filesystem-access/blob/master/modules/apps/filesystem-access-web/src/main/resources/META-INF/resources/view.jsp#L400-L402

<portlet:actionurl name="updateEmploye" var="addEmployeURL"></portlet:actionurl>


Another cut n paste error I believe, but reusing addEmployeURL as the var is not good; since you won't know how the JSP will be translated into a java servlet, you won't know if the right value will be assigned to the right var when you need it to - use unique names across the board to prevent potential bugs.

Here "updateEmploye " is the action method name so its hiting java class in (EX:EmployePortlet.java)


Like the action for adding an employee, the action for updating the employee should be separated out to it's own MVCActionCommand class.

public void updateEmploye(ActionRequest actionRequest, ActionResponse actionResponse) {
		_log.info("am inside of the empUpdate method");


A minor critique, this is really a debug message. This kind of thing you only want to see during debug and wouldn't want it to show up in normal info logging. Info is for more specific logging such as "About to update info for employee id XXX" sort of thing, but debug logging and trace logging you don't want to bleed out to higher logging levels.

public  EmpDetails updateEmploye(Long employeeid,String emplyename,int age,String qualifications,Long salary) {
		... 
		empDetails.setSalary(salary);


Okay, here's your first real significant bug. In empDetails() when you were adding employee details, there was code to determine the band based on the salary. But that code is missing from the update salary. So if I start in band B1 and someone updates my salary to 750000, you are not updating my band to B4.

If you move this to a separate method such as updateBand(EmpDetails empDetails), both the add and update could invoke the method to ensure the band is updated based upon salary value.
thumbnail
venky yuvan, modificado hace 6 años.

RE: Performing Crud Operations in Liferay 7

New Member Mensajes: 8 Fecha de incorporación: 21/04/17 Mensajes recientes
Thank you Sir @David H Nebinger
thumbnail
Santosh B Biradar, modificado hace 6 años.

RE: Performing Crud Operations in Liferay 7

Junior Member Mensajes: 41 Fecha de incorporación: 4/08/15 Mensajes recientes
Hi Venky n David H Nebinger,

Thanks for your great information and your valuable time.

Santosh B B(Zensar technology)
thumbnail
Santosh B Biradar, modificado hace 6 años.

RE: Performing Crud Operations in Liferay 7

Junior Member Mensajes: 41 Fecha de incorporación: 4/08/15 Mensajes recientes
Hi Venky,

Instead of ----- EmpDetails empDetails = new EmpDetailsImpl();

We can try like ------empDetailsLocalServiceUtil.createEmpDetails (CounterLocalServiceUtil.increment());

Please let me know,Am I rite or Notemoticon?
And Ya If Rite then Please let me know which is best Practiceemoticon

Regards
Santosh B B
thumbnail
David H Nebinger, modificado hace 6 años.

RE: Performing Crud Operations in Liferay 7

Liferay Legend Mensajes: 14918 Fecha de incorporación: 2/09/06 Mensajes recientes
Santosh B Biradar:
Instead of ----- EmpDetails empDetails = new EmpDetailsImpl();

We can try like ------empDetailsLocalServiceUtil.createEmpDetails (CounterLocalServiceUtil.increment());


You should never use the new EmpDetailsImpl() version. It may bypass installed model wrappers, service wrappers, etc.

Always use the latter to stay within the context of using the Liferay API which is always the best practice.








Come meet me at the 2017 LSNA!
thumbnail
Santosh B Biradar, modificado hace 6 años.

RE: Performing Crud Operations in Liferay 7

Junior Member Mensajes: 41 Fecha de incorporación: 4/08/15 Mensajes recientes
Hi David,
Thank you for your kind information,
So you meant to say is, second option is good.
Thanks
Santosh B B