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

liferay-service-builder_7_4_0.dtd

<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.4.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_4_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 Spring utilities, SOAP utilities, and Hibernate persistence classes to ease the development of services.

<service-builder>'s children
NameCardinality
authorOne or none
entityAny number
exceptionsOne or none
namespaceOnly one
service-builder-importAny number
<service-builder>'s attributes
NameValuesDefault
auto-import-default-references
auto-namespace-tables
change-tracking-enabled
dependency-injector
mvcc-enabled
optimize-db-indexes
package-path
short-no-such-exception-enabled
Element's model:

(author?, namespace, entity*, exceptions?, service-builder-import*)


@package-path Attribute of service-builder

The package-path value specifies the package of the generated code.

Required


@auto-import-default-references Attribute of service-builder

The auto-import-default-references value specifies whether or not to automatically default references. The default value is true.


@auto-namespace-tables Attribute of service-builder

The auto-namespace-tables value specifies whether or not to automatically namespace tables. The default value is false for core services and true for plugin services.


@change-tracking-enabled Attribute of service-builder

The change-tracking-enabled value specifies whether or not to enable change tracking by default for entities. Change tracking is a publishing framework that intercepts changes to data in entities' generated PersistenceImpl classes and queries made through Hibernate. It is highly encouraged to enable change tracking in the service-builder element instead of per entity. MVCC must be enabled to enable change tracking. The default value is false.


@dependency-injector Attribute of service-builder

The dependency-injector value specifies which dependency injector to use. Valid values are "spring" and "ds". For new OSGi modules, the default value is "ds", for existing modules or WARs, the default value is "spring".


@mvcc-enabled Attribute of service-builder

The mvcc-enabled value specifies whether or not to enable MVCC by default for entities to prevent lost updates. The default value is false.


@optimize-db-indexes Attribute of service-builder

The default value is true.


@short-no-such-exception-enabled Attribute of service-builder

The short-no-such-exception-enabled value specifies whether to try to shorten the no such exception class names when possible.

For example, if set to to true, generate the class NoSuchEntryException when the entity name is BlogsEntry and the namespace is Blogs. If set to false, generate the class NoSuchBlogsEntryException.

The default value is true.


<author> Child of service-builder

The author element is the name of the user associated with the generated code.


<namespace> Child of service-builder

The namespace element must be a unique namespace for this component. Table names will be prepended with this namespace. Generated JSON JavaScript will be scoped to this namespace as well (i.e., Liferay.Service.Test.* if the namespace is Test).


<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 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
localized-entityOne or none
orderOne or none
referenceAny number
tx-requiredAny number
<entity>'s attributes
NameValuesDefault
cache-enabled
change-tracking-enabled
data-source
deprecated
dynamic-update-enabled
external-reference-code
human-name
json-enabled
local-service
mvcc-enabled
name
persistence
persistence-class
plural-name
plural-variable-name
remote-service
session-factory
table
trash-enabled
tx-manager
uad-application-name
uad-auto-delete
uad-dir-path
uad-package-path
uuid
uuid-accessor
variable-name
versioned
Element's model:

(column*, localized-entity?, order?, finder*, reference*, tx-required*)


@name Attribute of entity

The name value specifies the name of the entity.

Required


@variable-name Attribute of entity

The variable-name value specifies the variable name of the name. If none is specified, one will be generated from the name.


@plural-name Attribute of entity

The plural-name value specifies the plural form of the name. If none is specified, one will be generated from the name.


@plural-variable-name Attribute of entity

The plural-variable-name value specifies the plural form of the variable name. If none is specified, one will be generated from the variable name.


@human-name Attribute of entity

The human-name value specifies the readable name to use when generating documentation for this entity. If none is specified, one will be generated from the name.


@table Attribute of entity

The table value specifies the name of the table that this entity maps to in the database. If this value is not set, then the name of the table is the same as the name of the entity.


@uuid Attribute of entity

If the uuid value is true, then the service will generate a UUID column for the service. This column will automatically be populated with a UUID. Developers will also be able to find and remove based on that UUID. The default value is false.


@uuid-accessor Attribute of entity

If the uuid-accessor value is true, then the service will generate a UUID column accessor for the service. This accessor will provide a fast and type-safe way to access entity's UUID.


@external-reference-code Attribute of entity

The external-reference-code value specifies if the service will generate an external reference code column for the service. The possible values are "none", "company", and "group". The default value is "none" and no external reference code column will be generated. The value "company" will generate an external reference code column scoped by company. The value "group" will generate an external reference code column scoped by group.

The deprecated value "true" maps to "company" and the deprecated "false" maps to "none".


@local-service Attribute of entity

If the local-service value is true, then the service will generate the local interfaces for the service. The default value is false.


@remote-service Attribute of entity

If the remote-service value is true, then the service will generate remote interfaces for the service. The default value is true.


@persistence Attribute of entity

If the persistence value is true, then the service will generate persistence interfaces and database files for the service. The default value is true.


@persistence-class Attribute of entity

The persistence-class value specifies the name of your custom persistence class. This class must implement the generated persistence interface or extend the generated persistence class. This allows you to override default behavior without modifying the generated persistence class.


@data-source Attribute of entity

The data-source value specifies the data source target that is set to the persistence class. The default value is the Liferay data source. This is used in conjunction with session-factory. See data-source-spring.xml.

You can generate classes to use a custom data source and session factory. Point "spring.configs" in portal.properties to load your custom Spring XML with the definitions of your custom data source and session factory. Then set the data-source and session-factory values to your custom values.


@session-factory Attribute of entity

The session-factory value specifies the session factory that is set to the persistence class. The default value is the Liferay session factory. This is used in conjunction with data-source. See data-source-spring.xml.

You can generate classes to use a custom data source and session factory. Point "spring.configs" in portal.properties to load your custom Spring XML with the definitions of your custom data source and session factory. Then set the data-source and session-factory values to your custom values.


@tx-manager Attribute of entity

The tx-manager value specifies the transaction manager that Spring uses. The default value is the Spring Hibernate transaction manager that wraps the Liferay data source and session factory. See data-source-spring.xml. Set this attribute to "none" to disable transaction management.


@cache-enabled Attribute of entity

The cache-enabled value specifies whether or not to cache this queries for this entity. Set this to false if data in the table will be updated by other programs. The default value is true.


@change-tracking-enabled Attribute of entity

The change-tracking-enabled value specifies whether or not to enable change tracking for this entity. Change tracking is a publishing framework that intercepts changes to data in the entity's generated PersistenceImpl class and queries made through Hibernate. It is highly encouraged to enable change tracking in the service-builder element instead of per entity. MVCC must be enabled to enable change tracking.


@dynamic-update-enabled Attribute of entity

The dynamic-update-enabled value specifies whether or not unmodified properties are excluded in the SQL update statement. The default value is the value of the attribute mvcc-enabled.


@json-enabled Attribute of entity

The json-enabled value specifies whether or not the entity should be annotated for JSON serialization. By default, if the remote-service value is true, then the json-enabled value is true.


@mvcc-enabled Attribute of entity

The mvcc-enabled value specifies whether or not to enable MVCC for this entity to prevent lost updates. The default value is based on the mvcc-enabled attribute in the service-builder element.


@trash-enabled Attribute of entity

The trash-enabled value specifies whether trash related methods should be generated or not.


@uad-application-name Attribute of entity

The uad-application-name value specifies the name of the application that the entity type belongs to in the GDPR UI.


@uad-auto-delete Attribute of entity

The uad-auto-delete value specifies whether or not the entity should be automatically deleted during the auto-anonymization.


@uad-dir-path Attribute of entity

The uad-dir-path value specifies the directory path of the generated UAD implementations.


@uad-package-path Attribute of entity

The uad-package-path value specifies the package path for the generated UAD classes.


@versioned Attribute of entity

If the versioned value is true, then the service will generate a version table, columns, and methods to version the entity.


@deprecated Attribute of entity

The deprecated value specifies whether the entity's services are deprecated.


<column> Child of localized-entity, entity

The column element represents a column in the database.

<column>'s attributes
NameValuesDefault
accessor
change-tracking-resolution-type
container-model
convert-null
db-name
entity
filter-primary
id-param
id-type
json-enabled
lazy
localized
mapping-table
method-name
name
parent-container-model
plural-name
primary
type
uad-anonymize-field-name
uad-nonanonymizable

@name Attribute of column

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

Required


@plural-name Attribute of column

The plural-name value specifies the plural form of the column name. If none is specified, one will be generated from the column name.


@db-name Attribute of column

Set db-name to map the field to a physical database column that is different from the column name.


@method-name Attribute of column

The method-name value is used to override the default getter/setter method names.

For example:

<column method-name="FOOBar" name="fooBar" type="String" />

The above column specifies that there will be a getter called pojo.getFOOBar() instead of the default pojo.getFooBar().


@type Attribute of column

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

For example:

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

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

Required


@primary Attribute of column

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.


@accessor Attribute of column

This accessor value specifies whether or not to generate an accessor for this column. This accessor will provide a fast and type-safe way to access column value.


@filter-primary Attribute of column

The filter-primary value specifies the column to use as the primary key column when using filter finders. Only one column should ever have this value set to true. If no column has this set to true, then the default primary column will be used.


@entity Attribute of column

If the entity and mapping-table attributes are specified, 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.

If you are creating a mapping table for an entity defined in another service.xml, you need to specify the full package path.

For example:

<column name="organizations" type="Collection" entity="com.liferay.portal.Organization" mapping-table="Foo_Organizations" />


@mapping-table Attribute of column

See the entity attribute's description for more information.


@id-type Attribute of column

The id-type and id-param values are used in order to create an auto-generated, auto-incrementing primary key when inserting records into a table. This can be implemented in 4 different ways, depending on the type of database being used. In all cases, the primary key of the model object should be assigned a value of null, and Hibernate will know to replace the null value with an auto-generated, auto-incremented value. If no id-type value is used, it is assumed that the primary key will be assigned and not auto-generated.

The first implementation uses a class to generate a primary key.

For example:

<column name="id" type="Integer" primary="true" id-type="class" id-param="com.liferay.counter.service.persistence.IDGenerator" />

In this implementation, the class specified in the id-param value will be called to retrieve a unique identifier (in the example above, an Integer) that will be used as the primary key for the new record. This implementation works for all supported databases.

The second implementation generates identifiers that are unique only when no other process is inserting data into the same table. This implementation should NOT be used in a clustered environment, but it does work for all supported databases.

For example:

<column name="id" type="Integer" primary="true" id-type="increment" />

The third implementation uses an identity column to generate a primary key.

For example:

<column name="id" type="Integer" primary="true" id-type="identity" />

In this implementation, the create table SQL generated for this entity will create an identity column that natively auto-generates a primary key whenever an insert occurs. This implementation is only supported by DB2, MySQL, and MS SQL Server.

The fourth implementation uses a sequence to generate a primary key.

For example:

<column name="id" type="Integer" primary="true" id-type="sequence" id-param="id_sequence" />

In this implementation, a create sequence SQL statement is created based on the id-param value (stored in /sql/sequences.sql). This sequence is then accessed to generate a unique identifier whenever an insert occurs. This implementation is only supported by DB2, Oracle, PostgreSQL, and SAP DB.


@id-param Attribute of column

See the id-type attribute's description for more information.


@change-tracking-resolution-type Attribute of column

The change-tracking-resolution-type value specifies how to resolve modification conflicts between columns when publishing. This value is only used when change tracking is enabled for the entity. When the change tracking resolution type value is not defined in the service, it is determined automatically by each column's data type. Primary key columns are set to "pk" and modified date columns are set to "ignore". Otherwise, the default value is "strict".

See com.liferay.portal.kernel.change.tracking.CTColumnResolutionType for available options.


@convert-null Attribute of column

The convert-null value specifies whether or not the column value is automatically converted to a non null value if it is null. This only applies if the type value is String. This is particularly useful if your entity is referencing a read only table or a database view so that Hibernate does not try to issue unnecessary updates. The default value is true.


@lazy Attribute of column

The lazy value is only valid when type is Blob. It specifies whether or not to do a lazy fetch for Blob. The default value is true.


@localized Attribute of column

The localized value specifies whether or not the value of the column can have different values for different locales. The default value is false. Localization can also be performed by using a generated localization table using the localized-entity and localized-column elements. The localized value cannot be set to true when the entity contains a localized-entity element. Using the localized-entity element with a separate table is recommended.


@json-enabled Attribute of column

The json-enabled value specifies whether or not the column should be annotated for JSON serialization. By default, if the json-enabled value in the entity element is true, then the json-enabled value in the column element is true.


@container-model Attribute of column

The container-model value specifies whether the column represents the primary key of a container model.


@parent-container-model Attribute of column

The parent-container-model value specifies whether the column represents the primary key of a parent container model.


@uad-anonymize-field-name Attribute of column

The uad-anonymize-field-name value specifies the anonymous user field that should be used to replace this column's value during auto anonymization. For example, if "fullName" is specified, the anonymous user's full name will replace this column's value during auto anonymization. The uad-anonymize-field-name value should only be used with user name columns (e.g. "statusByUserName").


@uad-nonanonymizable Attribute of column

The uad-nonanonymizable value specifies whether the column represents data associated with a specific user that should be reviewed by an administrator in the event of a GDPR compliance request. This implies the data cannot be anonymized automatically.


<localized-entity> Child of entity

The localized-entity element represents a table with a one to many mapping from the entity table to the localized entity table. The localized entity table is designed to be used instead of setting a column element's localized attribute to true. A defaultLanguageId column is generated for the entity table and several columns, finders, and update methods are generated for the localized entity.

<localized-entity>'s children
NameCardinality
columnAny number
finderAny number
localized-columnAt least one
orderOne or none
<localized-entity>'s attributes
NameValuesDefault
name
table
Element's model:

(column*, localized-column+, order?, finder*)


@name Attribute of localized-entity

The name value specifies the name of the localized entity. If this value is not set, then the parent entity's name is used with "Localization" appended.


@table Attribute of localized-entity

The table value specifies the name of the table that this localized entity maps to in the database. If this value is not set, then the name of the table is the same as the name of the localized entity.


<localized-column> Child of localized-entity

The localized-column element represents a column in the localization table.

<localized-column>'s attributes
NameValuesDefault
change-tracking-resolution-type
db-name
name

@name Attribute of localized-column

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

Required


@change-tracking-resolution-type Attribute of localized-column

The change-tracking-resolution-type value specifies how to resolve modification conflicts between columns when publishing. This value is only used when change tracking is enabled for the entity. When the changeTrackingResolutionType value is not defined in the service, it is determined automatically by each data column's type. Primary key columns are set to "pk" and modifiedDate columns are set to "ignore". Otherwise, the default value is "strict".

See com.liferay.portal.kernel.change.tracking.CTColumnResolutionType for available options.


@db-name Attribute of localized-column

Set db-name to map the field to a physical database column that is different from the localized-column name.


<order> Child of localized-entity, 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.

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-column>'s attributes
NameValuesDefault
case-sensitive
name
order-by

@name Attribute of order-column

The name value specifies the name of the entity.

Required


@case-sensitive Attribute of order-column

The case-sensitive value specifies whether or not the name is case sensitive. The default value is true.


@order-by Attribute of order-column

The order-by value specifies how to order the entity names. Possible values for this attribute are "asc" (ascending) or "desc" (descending).


<finder> Child of localized-entity, entity

The finder element represents a generated finder method.

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

(finder-column+)


@name Attribute of finder

The name value specifies the name of the finder method.

Required


@plural-name Attribute of finder

The plural-name value specifies the plural form of the finder name. If none is specified, one will be generated from the finder name.


@return-type Attribute of finder

The return-type value specifies the return type of the finder. Valid values are "Collection" or the name of the entity. If the value is "Collection", then this finder returns a list of entities. If the value is the name of the entity, then this finder returns at most one entity.

Required


@unique Attribute of finder

If the unique value is true, then the finder must return a unique entity.


@where Attribute of finder

Sorry, no documentation.


@db-index Attribute of finder

If the db-index value is true, then the service will automatically generate a SQL index for this finder. The default value is true.


<finder-column> Child of finder

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

<finder-column>'s attributes
NameValuesDefault
arrayable-operator
arrayable-pagination
case-sensitive
comparator
indexable
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 PersistenceImpl class. The Service Builder will also generate removeByCompanyId and countByCompanyId.

See com.liferay.portal.service.persistence.impl.LayoutPersistenceImpl for a good example.

Required


@case-sensitive Attribute of finder-column

The attribute case-sensitive is a boolean value and is only used if the column is a String value.


@comparator Attribute of finder-column

The attribute comparator takes in the values =, !=, <, <=, >, >=, or LIKE and is used to compare this column.


@arrayable-operator Attribute of finder-column

The attribute arrayable-operator takes in the values AND or OR and will generate an additional finder where this column's parameter takes an array instead of a single value. Every value in this array will be compared with the column using the comparator, and the conditions will be combined with either an AND or OR operator. For example, a finder column with the = comparator and an arrayable-operator of OR will act like an IN clause.


@arrayable-pagination Attribute of finder-column

The attribute arrayable-pagination is a boolean value and is used to signal if the entity column can be paginated.


@indexable Attribute of finder-column

The default value is true.


<reference> Child of entity

The reference element allows you to inject services from another service.xml within the same class loader. For example, if you inject the Resource entity, then you'll be able to reference the Resource services from your service implementation via the methods getResourceLocalService and getResourceService. You'll also be able to reference the Resource services via the variables resourceLocalService and resourceService.

<reference>'s attributes
NameValuesDefault
entity
package-path

@package-path Attribute of reference

See the comments in reference element.


@entity Attribute of reference

See the comments in reference element.


<tx-required> Child of entity

The tx-required element has a text value that will be used to match method names that require transactions. By default, the methods: add*, check*, clear*, delete*, set*, and update* require propagation of transactions. All other methods support transactions but are assumed to be read only. If you want additional methods to fall under transactions, add the method name to this element.

The tx-required attribute is deprecated in favor annotating the service impl method with com.liferay.portal.kernel.transaction.Transactional.


<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.


<service-builder-import> Child of service-builder

The service-builder-import allows you to split up a large Service Builder file into smaller files by aggregrating the smaller Service Builder into one file. Note that there can be at most one author element among all the files. There can also only be one and only one namespace element among all the files.

The attribute file is interpreted as relative to the file that is importing it.

<service-builder-import>'s attributes
NameValuesDefault
file

@file Attribute of service-builder-import

Set the comments in the service-builder-import element.

Required