liferay-service-builder_3_5_0.dtd: Elements - Entities - Source | Intro - Index
FRAMES / NO FRAMES

liferay-service-builder_3_5_0.dtd

This is the DTD for the Service Builder parameters for Liferay Portal.

<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 3.5.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_3_5_0.dtd">



<service-builder> Root element

The service-builder element is the root of the deployment descriptor for a Service Builder descriptor that is used to generate services available to portlets. The Service Builder saves the developer time by generating EJBs, Spring utilities, SOAP utilities, and Hibernate persistence classes to ease the development of services.

To run the service generator, go to /portal/portal-ejb (or /ext/ext-ejb) and type "ant build-service". The ant task will check for the existence of a file called "service.xml" that must exist in your current directory. It will parse that file to generate the service.

<service-builder>'s children
NameCardinality
entityAt least one
exceptionsOne or none
portletOnly one
<service-builder>'s attributes
NameValuesDefault
package-dir
root-dir
Element's model:

(portlet, entity+, exceptions?)


@root-dir Attribute of service-builder

The root-dir value specifies the root directory of the portal source code. If you are running the service builder in /portal/portal-ejb or /ext/ext-ejb, then the value is just ".." because the root is /portal or /ext.

The package-dir value specifies the package of the generated code. If the value is "com.liferay.portlet", then all generated code will fall inside "com.liferay.portlet" + the shortened portlet name. The portlet name is specified in the portlet element. For example, if the portlet name is "Message Boards", the generated code will fall under "com.liferay.portlet.messageboards".

Required


@package-dir Attribute of service-builder

The root-dir value specifies the root directory of the portal source code. If you are running the service builder in /portal/portal-ejb or /ext/ext-ejb, then the value is just ".." because the root is /portal or /ext.

The package-dir value specifies the package of the generated code. If the value is "com.liferay.portlet", then all generated code will fall inside "com.liferay.portlet" + the shortened portlet name. The portlet name is specified in the portlet element. For example, if the portlet name is "Message Boards", the generated code will fall under "com.liferay.portlet.messageboards".

Required


<portlet> Child of service-builder

The portlet element specifies the portlet that the generated services are designed for. Services are not limited to the specified portlet but are only grouped by portlet for easier maintenance.

<portlet>'s attributes
NameValuesDefault
name
short-name

@name Attribute of portlet

The name can be something like "Message Boards". It is used by the Service Builder in combination with the package-dir attribute.

The short-name can be something like "MB". This is used as a namespace to distinguish all the generated objects.

Required


@short-name Attribute of portlet

The name can be something like "Message Boards". It is used by the Service Builder in combination with the package-dir attribute.

The short-name can be something like "MB". This is used as a namespace to distinguish all the generated objects.

Required


<entity> Child of service-builder

An entity usually represents a business facade and a table in the database. If an entity does not have any columns, then it only represents a business facade. The Service Builder will always generate an empty business facade POJO if it does not exist. Upon subsequent generations, the Service Builder will check to see if the business facade already exists. If it exists and has additional methods, then the Service Builder will also update the EJB and SOAP wrappers.

If an entity does have columns, then the value object, the POJO class that is mapped to the database, and other persistence utilities are also generated based on the order and finder elements.

<entity>'s children
NameCardinality
columnAny number
finderAny number
orderOne or none
referenceAny number
<entity>'s attributes
NameValuesDefault
local-service
name
persistence-class
Element's model:

(column*, order?, finder*, reference*)


@name Attribute of entity

The name value specifies the name of the entity.

If the local-service is true, then the service will generate the local interfaces for the service as well as the remote interfaces.

If persistence-class specifies the name of your custom persistence class. This class must extend the generated persistence class. By extending the generated persistence class, you can add custom logic without modifying the generated class. You can also specify this value in portal.properties at runtime.

Required


@local-service Attribute of entity

The name value specifies the name of the entity.

If the local-service is true, then the service will generate the local interfaces for the service as well as the remote interfaces.

If persistence-class specifies the name of your custom persistence class. This class must extend the generated persistence class. By extending the generated persistence class, you can add custom logic without modifying the generated class. You can also specify this value in portal.properties at runtime.


@persistence-class Attribute of entity

The name value specifies the name of the entity.

If the local-service is true, then the service will generate the local interfaces for the service as well as the remote interfaces.

If persistence-class specifies the name of your custom persistence class. This class must extend the generated persistence class. By extending the generated persistence class, you can add custom logic without modifying the generated class. You can also specify this value in portal.properties at runtime.


<column> Child of entity

The column element represents a column in the database.

<column>'s attributes
NameValuesDefault
entity
mapping-key
mapping-table
name
primary
type

@name Attribute of column

The name value specifies the getter and setter name in the entity.

The type value specifies whether the column is a String, Boolean, or int, etc.

For example:

<column name="companyId" type="String" />

The above column specifies that there will be a getter called pojo.getCompanyId() that will return a String.

If the primary value is set to true, then this column is part of the primary key of the entity. If multiple columns have the primary value set to true, then a compound key will be created.

See com.liferay.portal.service.persistence.LayoutPK for an example of a compound primary key.

If the entity and mapping-key attributes are specified and mapping-table is not, then the Service Builder will assume you are specifying a one to many relationship.

For example:

<column name="shoppingItemPrices" type="Collection" entity="ShoppingItemPrice" mapping-key="itemId" />

The above column specifies that there will be a getter called pojo.getShoppingItemPrices() that will return a collection. It will map to a column called itemId in the table that maps to the entity ShoppingItemPrice.

If the entity and mapping-table attributes are specified and mapping-key is not, then the Service Builder will assume you are specifying a many to many relationship.

For example:

<column name="roles" type="Collection" entity="Role" mapping-table="Groups_Roles" />

The above column specifies that there will be a getter called pojo.getRoles() that will return a collection. It will use a mapping table called Groups_Roles to give a many to many relationship between groups and roles.

Required


@type Attribute of column

The name value specifies the getter and setter name in the entity.

The type value specifies whether the column is a String, Boolean, or int, etc.

For example:

<column name="companyId" type="String" />

The above column specifies that there will be a getter called pojo.getCompanyId() that will return a String.

If the primary value is set to true, then this column is part of the primary key of the entity. If multiple columns have the primary value set to true, then a compound key will be created.

See com.liferay.portal.service.persistence.LayoutPK for an example of a compound primary key.

If the entity and mapping-key attributes are specified and mapping-table is not, then the Service Builder will assume you are specifying a one to many relationship.

For example:

<column name="shoppingItemPrices" type="Collection" entity="ShoppingItemPrice" mapping-key="itemId" />

The above column specifies that there will be a getter called pojo.getShoppingItemPrices() that will return a collection. It will map to a column called itemId in the table that maps to the entity ShoppingItemPrice.

If the entity and mapping-table attributes are specified and mapping-key is not, then the Service Builder will assume you are specifying a many to many relationship.

For example:

<column name="roles" type="Collection" entity="Role" mapping-table="Groups_Roles" />

The above column specifies that there will be a getter called pojo.getRoles() that will return a collection. It will use a mapping table called Groups_Roles to give a many to many relationship between groups and roles.

Required


@primary Attribute of column

The name value specifies the getter and setter name in the entity.

The type value specifies whether the column is a String, Boolean, or int, etc.

For example:

<column name="companyId" type="String" />

The above column specifies that there will be a getter called pojo.getCompanyId() that will return a String.

If the primary value is set to true, then this column is part of the primary key of the entity. If multiple columns have the primary value set to true, then a compound key will be created.

See com.liferay.portal.service.persistence.LayoutPK for an example of a compound primary key.

If the entity and mapping-key attributes are specified and mapping-table is not, then the Service Builder will assume you are specifying a one to many relationship.

For example:

<column name="shoppingItemPrices" type="Collection" entity="ShoppingItemPrice" mapping-key="itemId" />

The above column specifies that there will be a getter called pojo.getShoppingItemPrices() that will return a collection. It will map to a column called itemId in the table that maps to the entity ShoppingItemPrice.

If the entity and mapping-table attributes are specified and mapping-key is not, then the Service Builder will assume you are specifying a many to many relationship.

For example:

<column name="roles" type="Collection" entity="Role" mapping-table="Groups_Roles" />

The above column specifies that there will be a getter called pojo.getRoles() that will return a collection. It will use a mapping table called Groups_Roles to give a many to many relationship between groups and roles.


@entity Attribute of column

The name value specifies the getter and setter name in the entity.

The type value specifies whether the column is a String, Boolean, or int, etc.

For example:

<column name="companyId" type="String" />

The above column specifies that there will be a getter called pojo.getCompanyId() that will return a String.

If the primary value is set to true, then this column is part of the primary key of the entity. If multiple columns have the primary value set to true, then a compound key will be created.

See com.liferay.portal.service.persistence.LayoutPK for an example of a compound primary key.

If the entity and mapping-key attributes are specified and mapping-table is not, then the Service Builder will assume you are specifying a one to many relationship.

For example:

<column name="shoppingItemPrices" type="Collection" entity="ShoppingItemPrice" mapping-key="itemId" />

The above column specifies that there will be a getter called pojo.getShoppingItemPrices() that will return a collection. It will map to a column called itemId in the table that maps to the entity ShoppingItemPrice.

If the entity and mapping-table attributes are specified and mapping-key is not, then the Service Builder will assume you are specifying a many to many relationship.

For example:

<column name="roles" type="Collection" entity="Role" mapping-table="Groups_Roles" />

The above column specifies that there will be a getter called pojo.getRoles() that will return a collection. It will use a mapping table called Groups_Roles to give a many to many relationship between groups and roles.


@mapping-key Attribute of column

The name value specifies the getter and setter name in the entity.

The type value specifies whether the column is a String, Boolean, or int, etc.

For example:

<column name="companyId" type="String" />

The above column specifies that there will be a getter called pojo.getCompanyId() that will return a String.

If the primary value is set to true, then this column is part of the primary key of the entity. If multiple columns have the primary value set to true, then a compound key will be created.

See com.liferay.portal.service.persistence.LayoutPK for an example of a compound primary key.

If the entity and mapping-key attributes are specified and mapping-table is not, then the Service Builder will assume you are specifying a one to many relationship.

For example:

<column name="shoppingItemPrices" type="Collection" entity="ShoppingItemPrice" mapping-key="itemId" />

The above column specifies that there will be a getter called pojo.getShoppingItemPrices() that will return a collection. It will map to a column called itemId in the table that maps to the entity ShoppingItemPrice.

If the entity and mapping-table attributes are specified and mapping-key is not, then the Service Builder will assume you are specifying a many to many relationship.

For example:

<column name="roles" type="Collection" entity="Role" mapping-table="Groups_Roles" />

The above column specifies that there will be a getter called pojo.getRoles() that will return a collection. It will use a mapping table called Groups_Roles to give a many to many relationship between groups and roles.


@mapping-table Attribute of column

The name value specifies the getter and setter name in the entity.

The type value specifies whether the column is a String, Boolean, or int, etc.

For example:

<column name="companyId" type="String" />

The above column specifies that there will be a getter called pojo.getCompanyId() that will return a String.

If the primary value is set to true, then this column is part of the primary key of the entity. If multiple columns have the primary value set to true, then a compound key will be created.

See com.liferay.portal.service.persistence.LayoutPK for an example of a compound primary key.

If the entity and mapping-key attributes are specified and mapping-table is not, then the Service Builder will assume you are specifying a one to many relationship.

For example:

<column name="shoppingItemPrices" type="Collection" entity="ShoppingItemPrice" mapping-key="itemId" />

The above column specifies that there will be a getter called pojo.getShoppingItemPrices() that will return a collection. It will map to a column called itemId in the table that maps to the entity ShoppingItemPrice.

If the entity and mapping-table attributes are specified and mapping-key is not, then the Service Builder will assume you are specifying a many to many relationship.

For example:

<column name="roles" type="Collection" entity="Role" mapping-table="Groups_Roles" />

The above column specifies that there will be a getter called pojo.getRoles() that will return a collection. It will use a mapping table called Groups_Roles to give a many to many relationship between groups and roles.


<order> Child of entity

The order element specifies a default ordering and sorting of the entities when they are retrieved from the database.

<order>'s children
NameCardinality
order-columnAt least one
<order>'s attributes
NameValuesDefault
by
Element's model:

(order-column+)


@by Attribute of order

Set the by attribute to "asc" or "desc" to order by ascending or descending.


<order-column> Child of order

The order-column element allows you to order the entities by specific columns.

<order-column>'s attributes
NameValuesDefault
case-sensitive
name
order-by

@name Attribute of order-column

The attributes of the order-column element allows you to fine tune the ordering of the entity.

For example:

<order by="asc"> <order-column name="parentLayoutId" /> <order-column name="priority" /> </order>

The above settings will order by parentLayoutId and then by priority in an ascending manner.

For example:

<order by="asc"> <order-column name="name" case-sensitive="false" /> </order>

The above settings will order by name and will not be case sensitive.

For example:

<order> <order-column name="articleId" order-by="asc" /> <order-column name="version" order-by="desc" /> </order>

The above settings will order by articleId in an ascending manner and then by version in a descending manner.

Required


@case-sensitive Attribute of order-column

The attributes of the order-column element allows you to fine tune the ordering of the entity.

For example:

<order by="asc"> <order-column name="parentLayoutId" /> <order-column name="priority" /> </order>

The above settings will order by parentLayoutId and then by priority in an ascending manner.

For example:

<order by="asc"> <order-column name="name" case-sensitive="false" /> </order>

The above settings will order by name and will not be case sensitive.

For example:

<order> <order-column name="articleId" order-by="asc" /> <order-column name="version" order-by="desc" /> </order>

The above settings will order by articleId in an ascending manner and then by version in a descending manner.


@order-by Attribute of order-column

The attributes of the order-column element allows you to fine tune the ordering of the entity.

For example:

<order by="asc"> <order-column name="parentLayoutId" /> <order-column name="priority" /> </order>

The above settings will order by parentLayoutId and then by priority in an ascending manner.

For example:

<order by="asc"> <order-column name="name" case-sensitive="false" /> </order>

The above settings will order by name and will not be case sensitive.

For example:

<order> <order-column name="articleId" order-by="asc" /> <order-column name="version" order-by="desc" /> </order>

The above settings will order by articleId in an ascending manner and then by version in a descending manner.


<finder> Child of entity

The finder element represents a generated finder method.

<finder>'s children
NameCardinality
finder-columnAt least one
<finder>'s attributes
NameValuesDefault
db-index
name
return-type
where
Element's model:

(finder-column+)


@name Attribute of finder

Sorry, no documentation.

Required


@return-type Attribute of finder

Sorry, no documentation.

Required


@where Attribute of finder

Sorry, no documentation.


@db-index Attribute of finder

Sorry, no documentation.


<finder-column> Child of finder

The finder-column element specifies the columns to find by.

<finder-column>'s attributes
NameValuesDefault
check-array
name

@name Attribute of finder-column

The name value specifies the name of the finder method.

For example:

<finder name="CompanyId" return-type="Collection"> <finder-column name="companyId" /> </finder>

The above settings will create a finder with the name findByCompanyId that will return a Collection and require a given companyId. It will also generate several more findByCompanyId methods that take in pagination fields (int begin, int end) and more sorting options. The easiest way to understand this is to look at a generated Persistence class. The Service Builder will also generate removeByCompanyId and countByCompanyId.

See com.liferay.portal.service.persistence.LayoutPersistence for a good example.

The attribute check-array is deprecated and will be removed in the next release.

Required


@check-array Attribute of finder-column

The name value specifies the name of the finder method.

For example:

<finder name="CompanyId" return-type="Collection"> <finder-column name="companyId" /> </finder>

The above settings will create a finder with the name findByCompanyId that will return a Collection and require a given companyId. It will also generate several more findByCompanyId methods that take in pagination fields (int begin, int end) and more sorting options. The easiest way to understand this is to look at a generated Persistence class. The Service Builder will also generate removeByCompanyId and countByCompanyId.

See com.liferay.portal.service.persistence.LayoutPersistence for a good example.

The attribute check-array is deprecated and will be removed in the next release.


<reference> Child of entity

The reference element will automatically populate the ejb-jar.xml and other required XML files with the proper reference from one service to another service.

<reference>'s attributes
NameValuesDefault
entity
package-path

@package-path Attribute of reference

See the comments in reference element.

Required


@entity Attribute of reference

See the comments in reference element.

Required


<exceptions> Child of service-builder

The exceptions element contain a list of generated exceptions. This doesn't save a lot of typing, but can still be helpful.

<exceptions>'s children
NameCardinality
exceptionAny number
Element's model:

(exception*)


<exception> Child of exceptions

See the comments in exceptions element.