Queries are defined in the tag <select> . They can be multiple. In this case, repeat the tag <select> as many times as objects to be displayed in the search view.
Each tag <select>, must specify on the object on which we did the research, the attribute model = "" and a label, the attribute title = "". The tag <select> define search criteria by object and maps the fields of the object in the result fields.
Example search on a Partner object:
<select model="com.axelor.sale.db.Order" title="Sale Order" orderBy="date,-value" >
Results can be sorted by tag orderBy which takes as parameter fields of the object on which we did the research, separated by commas.
Inside the tag <select> you can use the following tags:
Inside the <where> tag is used <input> . each test
Example: Search records where the field contactName of the object shown in the tag <select> contains ( contains ), which was entered in the criterion name .
<input name="name" field="contactName" matchStyle="contains"/>
Possible values matchStyle option:
Tags <select> and <input> can have an optional requirement embodied by the tag if that can contain any boolean expression Groovy to evaluate the input values. If the result of the expression is false, then these elements are omitted.
Clause where is reconstructed from XML attributes match = "any | all" corresponding to OR and AND. All records corresponding to an element input given are returned even if the game uses attribute is all . (Note 1)
Note 1: If the tag <input> is used several times on the same test, the operator is automatically used OR. This happens in the following example with the standard phone :
<input name="telephone" field="contactFixedPhone1" matchStyle="contains"/>
<input name="telephone" field="contactMobilePhonePerso"
Example:
<select model="com.axelor.sale.db.Order" title="Sale Order" orderBy="date,-value">
<field name="customer.fullName" as="customer"/>
<field name="items[].product.name" as="product"/>
<field name="createDate" as="date"/>
<field name="amount" as="value"/>
<where match="all">
<input name="customer" field="customer.fullName" matchStyle="contains"/>
<input name="customer" field="customer.email" matchStyle="contains"/>
<input name="date" field="createDate"/>
<input name="product" field="items[].product"/>
</where>
</select>
The result of this research led to the following JPQL query:
SELECT
_customer.fullName AS customer,
_items_product.name AS product,
self.createDate AS date,
self.amount AS value
LEFT JOIN self.customer AS _customer
LEFT JOIN self.items AS _items
LEFT JOIN _items.product AS _items_product
WHERE
(_customer.fullName LIKE :customer OR _customer.email LIKE :customer) AND (self.createDate = :date) AND (_items.product = :product)
ORDER BY
date, value DESC
Note : Note that the relational fields joined with the LEFT JOIN to include NULL records so that the game does not affect any records.