Subscribe via RSS Feed

Liferay Service builder – Step by Step

February 8, 2013 1 Comment

Liferay Service Builder is a specific feature in Lifray 6.0 which facilitate us database centric Development.

In Liferay Eclipse IDE,

1> Select a new Service Builder Option

2> Create package path and namespace for the service builder

3> Clicking on finish, it will make a Service.xml file for which the Structure will be -


<!– PK fields –>


 <!– Audit fields –>


<column name=“userId” type=“long” />

<column name=“userName” type=“String” />

<column name=“createDate” type=“Date” />

<column name=“modifiedDate” type=“Date” />

 <!– Other fields –>


<column name=“field2″ type=“boolean” />

<column name=“field3″ type=“int” />

<column name=“field4″ type=“Date” />

<column name=“field5″ type=“String” />

 <!– Order –>


<order-column name=“field1″ />


 <!– Finder methods –>


<finder-column name=“field2″ />



Now for a table like UOM with 2 fields uom_id and uom_desc the service.xml file will be -

<column name=“uom_id” type=“long” primary=“true”></column>

<column name=“uom_desc” type=“String”></column>


4> Run the build-service target in Ant Build.xml

5> It will generate all the necessary files for the service layer.

6> From the Portlet we can access all the useful methods for the service layer such as -

uom uom = new uomImpl(); // new entity object initialisation

uomLocalServiceUtil.adduom(uom);//Add Entity

uomLocalServiceUtil.deleteuom(uom); // Delete Entity

uomLocalServiceUtil.updateuom(uom); // Update Entity

 Except those autogenerated methods, there are ways to write Custom Entity fetch specific code and other codes. But those should be created and used when the code specific in service layer requires to do so.

Enter your email address:

Delivered by FeedBurner