The service.xml file is available in the /docroot/WEB-INF folder. A typical service.xml file looks like this.
<?xml version="1.0"?> <!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 5.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_5_0_0.dtd"> <service-builder package-path="com.sample.portlet.library"> <namespace>Library</namespace> <entity name="Book" local-service="true" remote-service="false"> <!-- PK fields --> <column name="bookId" type="long" primary="true" /> <!-- Group Instance --> <column name="groupId" type="long" /> <!-- Audit fields --> <column name="companyId" type="long" /> <column name="userId" type="long" /> <column name="userName" type="String" /> <column name="createDate" type="Date" /> <column name="modifiedDate" type="Date" /> <!.. Other Fields ..> <column name="title" type="String" /> </entity> </service-builder> |
Let us look at the elements and their functions in the service.xml file.
<service-builder package-path="com.sample.portlet.library"> |
The package-path element specifies the package path that the class will generate to. In this example, classes will generate to WEB-INF/src/com/sample/portlet/library/.
<namespace>Library</namespace> |
The namespace element must be a unique namespace for this component. The names of tables names will be prepended with this namespace element.
<entity name="Book" local-service="true" remote-service="false"> |
The entity name is the database table you want to create.