You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/refguide/modeling/domain-model/entities/view-entities/_index.md
+51-13Lines changed: 51 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,31 +7,54 @@ cascade:
7
7
#If moving or renaming this doc file, implement a temporary redirect and let the respective team know they should update the URL in the product. See Mapping to Products for more details.
8
8
---
9
9
10
-
{{% alert color="info" %}} This feature was introduced in Mendix 10.19 and is currently in beta. For more information, see [Beta and Experimental Releases](/releasenotes/beta-features/). {{% /alert %}}
10
+
{{% alert color="info" %}}
11
+
This feature was introduced in Studio Pro 10.19 and is currently in beta. For more information, see [Beta and Experimental Releases](/releasenotes/beta-features/).
12
+
{{% /alert %}}
11
13
12
14
## Introduction
13
15
14
-
A view entity represents the result set of a stored [OQL query](/refguide/oql/) and can be used similarly to a [persistable entity](/refguide/persistability/#persistable). This concept is similar to the function of views in general database technology. Whenever a view entity is retrieved via a page or a microflow, the corresponding OQL query executes to fetch the relevant data. Consequently, the result set of a view entity is not stored as a separate table in the database (like a materialized view). Instead, the query runs each time the view entity is accessed, dynamically retrieving the data.
16
+
A view entity represents the result set of a stored [OQL query](/refguide/oql/) and can be used similarly to a [persistable entity](/refguide/persistability/#persistable). This concept is similar to the function of views in general database technology. Whenever a view entity is retrieved via a page or a microflow, the corresponding OQL query runs and fetches the relevant data. Consequently, the result set of a view entity is not stored as a separate table in the database (like a materialized view). Instead, the query runs each time the view entity is accessed, dynamically retrieving the data.
15
17
16
18
During modeling, changes to the underlying entities used in the OQL query affect the options available within the query. At runtime, any changes to the data in the underlying entities immediately impact the data available through the view entity.
17
19
18
20
View entities can also reference other view entities, allowing for more complex structures and better data organization.
19
21
20
-
{{% alert color="info" %}} View entities are read-only. To change the resulting data of a view entity retrieval, the source data should be modified. For this purpose, you can set up a microflow to map a view object to object (or objects) of their corresponding source entity/entities and commit those. {{% /alert %}}
22
+
{{% alert color="info" %}}
23
+
View entities are read-only. To change the resulting data of a view entity retrieval, the source data should be modified. For this purpose, you can set up a microflow to map a view object to an object (or objects) of their corresponding source entity (or entities) and commit those.
24
+
{{% /alert %}}
21
25
22
-
## Enabling OQL Version 2
26
+
## Prerequisites
23
27
24
-
Your app must use OQL version 2 to use view entities. You can change this setting by clicking **App** > **Settings** > **Runtime** and setting [OQL version 2](/refguide/app-settings/#oql-version-2) to **Yes**. You can also drag a new view entity from the toolbar or **Toolbox** to the domain model, in which Studio Pro will confirm setting the OQL version to 2.
28
+
Your app must use OQL version 2 to use view entities. You can change this setting by clicking **App 'APP_NAME'** > **Settings** > **Runtime** and setting [OQL version 2](/refguide/app-settings/#oql-version-2) to **Yes**. Alternatively, you can drag a new view entity from the toolbar or **Toolbox** to the domain model, which opens a dialog box where you can confirm upgrading to OQL version 2 if it has not been upgraded yet.
25
29
26
30
## Properties
27
31
28
-
After adding a view entity, you can specify the OQL query by double-clicking the entity to open the view entity properties dialog:
32
+
Double-click a view entity to open its Properties dialog box. An example of a view entity's properties dialog box is represented in the image below:
View entity properties consist of the following sections:
37
+
38
+
*[General](#general)
39
+
*[OQL editor](#oql-editor)
40
+
*[Access rules](#access-rules)
41
+
*[Documentation](#documentation)
42
+
43
+
### General Section {#general}
44
+
45
+
#### Name {#name}
46
+
47
+
The name property defines the name of the view entity. This name is used to refer to the view entity in forms, microflows, queries, constraints, etc.
48
+
49
+
The name has to be unique only within the domain model of a module. You can have two view entities with the same name, provided they are in the domain models of different modules.
33
50
34
-
The **General** field contains the **OQL editor** and the **Preview data** table.
51
+
#### Image {#image}
52
+
53
+
The image property can be used to associate an image with a view entity. In the domain model, this image is shown in the top-left corner of the view entity. The image is also shown in other places where view entities are mentioned, such as the entity selection pop-up window when selecting an entity for a data view.
54
+
55
+
### OQL Editor Section {#oql-editor}
56
+
57
+
This section contains the **OQL editor** and the **Preview data** table.
35
58
36
59
The **OQL editor** allows you to write the query that defines this view entity. While writing this query, the editor suggests names of the entities and attributes in your domain model, as well as allowed clauses, operators, and functions. If the query is not valid, a list of validation errors will be displayed underneath the editor with the line and column number of the place where the error was found.
37
60
@@ -41,18 +64,33 @@ The resulting names and types of the attributes will be displayed as column head
41
64
The **Preview data** table tries to retrieve the data using your OQL query from the running app. This means if you have changed your domain model since you last started the app, you can run into errors when the OQL query uses attributes or entities that do not yet exist in the version of the app that is running.
42
65
{{% /alert %}}
43
66
44
-
### Access Rules
67
+
### Access Rules {#access-rules}
45
68
46
69
When the security level of the app is set to **Production**, the **Access rules** tab becomes available in the view entity properties.
47
70
48
71
Assigning write access to an attribute allows the selected module role to edit the in-memory representation of the query result, but not the underlying source entity. The access level set on the view entity is the sole determining factor for whether a role can read or write to it. The access levels of underlying entities are not considered. This is crucial to prevent unintended exposure of data that is restricted at the source entity level.
49
72
50
-
Direct writing from the view entity to its source entities is not supported, but you can set up a microflow to retrieve and update the source entities to achieve this functionality.
73
+
Direct writing from the view entity to its source entities is not supported, but you can set up a microflow to retrieve and update the source entities to achieve this.
51
74
52
-
### Documentation
75
+
### Documentation {#documentation}
53
76
54
77
You can add any local information about the view entity in this tab. This is also available to other users working on the app.
55
78
56
-
## Using a View Entity
79
+
## Using a View Entity
80
+
81
+
After creating a view entity in the domain model, it can be used in microflows and pages like any other entity. For more information, see [Use View Entities](/refguide/use-view-entities/) and [OQL](/refguide/oql/).
82
+
83
+
## Read More
84
+
85
+
For specific use case scenarios, see the following:
57
86
58
-
After creating a view entity in the domain model, it can be used in microflows and pages like any other entity. For more information, see [Use View Entities](/refguide/use-view-entities/).
0 commit comments