Entity join

images/download/attachments/167859497/image-2024-1-22_18-8-47-version-1-modificationdate-1705943327256-api-v2.png

An Entity join uses the On condition to include assigned instances of the entity type selected as the Entity in a search under the name specified as the Join alias.

In contrast to all other Joins, the Entity join is based exclusively on the condition explicitly formulated in the Join alias. Other relationships between entities in the search and the joined instances are neither expected nor taken into account.

The relationship to the entity type selected as the Entity can therefore be defined completely arbitrarily via the On condition.


IMPORTANT◄ The access restrictions that may apply to the main entity of a search due to ownership, participation and Company authorizations categorically do not apply to access to instances of the entity type selected as the Entity.


Configuration

Parameter

Data type

Description

Specific parameter

Entity

Entity type

Any entity type can be selected as the Entity. The Combobox also offers options that cannot be selected as a (main) 'entity' for a search. Example:

images/download/attachments/167859497/image-2024-1-22_12-6-26-version-1-modificationdate-1705921587052-api-v2.png

Generic parameters

Join alias

String

A string that uniquely identifies the entity provided by the join as a prefix in the data field path must be specified as the Join alias.

images/download/attachments/167859497/image-2024-1-22_18-9-19-version-1-modificationdate-1705943359894-api-v2.png ... enables ... images/download/attachments/167859497/image-2024-1-22_18-11-56-version-1-modificationdate-1705943516212-api-v2.png

Characters that are not permitted for a Join alias (such as the space or period) are automatically replaced by an underscore:

images/download/attachments/167859497/image-2024-1-22_13-9-43-version-1-modificationdate-1705925383386-api-v2.png ... is replaced by ... images/download/attachments/167859497/image-2024-1-22_13-10-26-version-1-modificationdate-1705925426296-api-v2.png

images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg CAUTIONimages/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg If the internal name of a data field is specified as the Join alias, the Join alias overrides this property name for the context of the search. As long as the data field in question is not accessed within the search, this is not critical and may therefore remain unnoticed until a corresponding access is attempted.

Join type

Enumeration value

By default, the Join type 'Left' (LEFT) is preset so that the Entity join has no restrictive effect on the search even if the On condition does not return any matches.

The Join type 'Inner' (INNER) can act as a restriction for the search if the Optional option is unchecked. Only results for which the Entity join has 'contributed' at least one match based on the On condition will then appear in the search result.

Optional

Boolean

The Optional option is checked by default. The relevant Join is then only transferred to the database query at runtime if projections require this.

NOTE◄ As long as a join defined as Optional is not executed at runtime due to a lack of necessity, any errors in its configuration cannot be detected. This can give the misleading impression that a certain On condition only works in an optional join. In reality, however, the 'optional' join may not take place at all on the database side.

On condition

Restriction

The On condition optionally defines which criterion (see Restrictions) must be fulfilled for a join to contribute data to the search result. Typically, the On condition relates data from entities that are 'candidates' for an assignment from the perspective of the join to data from entities that may be the target of the assignment. Projections for 'candidates' use the Join alias as a prefix.

If no On condition is specified, the Entity join assigns all instances of the entity type selected by Entity. Depending on other parameters in the search, their number can multiply the number of search result rows.


NOTE◄ In the language used for the Join type (LEFT, INNER, RIGHT), the 'candidates' are always on the 'right-hand side' of the relationship established by the join. The positioning within any Field restriction used as a check value or compare value is irrelevant in this respect:

images/download/attachments/167859497/image-2024-1-22_18-13-33-version-1-modificationdate-1705943613226-api-v2.png is interchangable to images/download/attachments/167859497/image-2024-1-22_18-14-10-version-1-modificationdate-1705943650679-api-v2.png

Examples

Simple use case: Access to the owner account of a user

Like every entity type, Users also use a Long property 'owner' (ownerId), which can be used to refer to the 'ID' (id) property of a company that is considered the 'owner' of a specific user.

The data model of the entity (here: user) only contains the Long value of the reference, so that detailed data on the owner company must be included in a search via a join if required.

Specifically, a CSV search should combine the 'username' (username) and the 'owner' (ownerId) properties from the user account with the 'account number' (address.accNumber) address property of the owner company.

Configuration:

The screenshot on the right shows the configuration for the CSV search with Projections and Joins:

  • The first Property projection directly accesses the 'username' (username) property in the user account.

  • The second Property projection directly accesses the 'owner' (ownerId) property in the user account.

  • The third Property projection refers to the 'owner' company via Join alias cmp in order to return its 'account number' (address.accNumber) address property.

The assignment of the 'owner' company for each user is regulated by the Entity join:

  • The 'Company account' (CompanyAccount) entity type is selected as the Entity.

  • The name cmp (as an abbreviation for 'Company') was arbitrarily assigned as the Join alias. In less straightforward scenarios, a more meaningful alias name (e.g. ownerCompany) would certainly be recommended.

  • 'Inner' is selected as the Join type, as our list should only contain users for whom the On condition is fulfilled.

  • The Optional option has been unchecked so that the 'Inner' join also has a restrictive effect if none of the output columns explicitly refer to the cmp alias (see 'Variant' below).

  • The On condition requires that the reference in the 'owner' (ownerId) property must match the 'ID' of a company (cmp.id) so that it is assigned to the user in the search result.

images/download/attachments/167859497/image-2024-1-22_18-6-56-version-1-modificationdate-1705943217094-api-v2.png

A special feature of this use case is that the join can only return exactly one or no hits for each user among the company accounts and not several,

There are two cases in which the join does not provide a company account:

  • The company account referenced as 'owner' no longer exists because it has been deleted.

  • 'No owner' is referenced for a user. In this case, the 'owner' (ownerId) property is automatically assigned the value -1, which no company account can use.

In both cases, no assignment is made, which in this case (in conjunction with the 'Inner' Join type) means that the user in question does not appear in the results list.

Variant:

Instead of a CSV search, a 'normal' Search is carried out, which lists complete Users instances to which an 'owner' account has been successfully assigned.

In the Search builder, the 'Search type' for the existing configuration can be changed from CSV search to Search. This eliminates the Projections and only the Entity join shown on the right remains:

  • As we have unchecked the Optional option, the 'Inner' Join type has a restrictive effect on the search as a whole, even without the existence of a projection that refers to the cmp alias. Only user accounts that refer to a specific 'owner' company appear in the results list.

  • If the Optional option is checked, the results list may also contain Users who are not assigned an 'owner' or who refer to a company account as 'owner' that does not (or no longer) exist. In this case, the Entity join would no longer have any influence on the result, as it neither 'feeds' Projections nor acts as a restriction. It is therefore not mapped in the database, even though it is included in the configuration.

images/download/attachments/167859497/image-2024-1-22_18-5-14-version-1-modificationdate-1705943115124-api-v2.png

Special use case: SELF JOIN to search for duplicates

Many configurations such as Association criteria or Event handlingg have a 'name' (name) property in which a text can be entered that should identify the configuration element in question with appropriate precision to enable quick identification (e.g. in an overview or a dropdown).

It is not absolutely necessary for the assigned 'name' within the respective entity type to be unique, as these configurations – like all entities – are identified by the system using their unique and automatically assigned 'ID' (id).

In order to maintain a certain degree of transparency, it can do no harm, for example, to search periodically or on an ad hoc basis for names that have been assigned more than once in the context of implementation.

In the following example, a CSV search determines such 'duplicates' for Association criteria.

Configuration:

As a minimum, the CSV search should contain three Projections for output columns:

  • The first Property projection refers to the 'name' (name) property, i.e. the key value for recognizing 'duplicates'.

  • The second Property projection specifies the 'ID' (id) of the asssociation criterion that is evaluated as the original in the result line.

  • The third Property projection should specify the alternative 'ID' (alias.id) of an identified 'duplicate' with the same name. The duplicate search is based here on an Entity join with the Join alias alias.

    • You could call the Entity join a 'SELF JOIN', as it refers to the same entity type in the Entity parameter that the search itself addresses (here: association criterion).

    • The Join type 'Inner' in conjunction with the unchecked Optional option ensures that only rows for which the alias contributes a value are output in the result.

    • The On condition (see below for details) is intended to ensure that the join assigns all other assignment criteria for which the same 'name' (name) is specified to each association criterion.

images/download/attachments/167859497/image-2024-1-22_18-2-39-version-1-modificationdate-1705942959235-api-v2.png

The screenshot on the right shows the On condition that maps the criterion for the assignment of duplicates as a Search junction with an AND junction from two instances of the Field restriction:

  • The first Field restriction ensures that a comparison for the 'ID' (id vs. alias.id) property does not result in a match (!=). Otherwise the SELF JOIN would identify each association criterion as a duplicate of itself.

  • The second Field restriction ensures that the 'Name' (name vs. alias.nam) property matches.

The alias data record should only be assigned to the parent data record if both conditions are met.


IMPORTANT◄ If the search is carried out in a context in which access restrictions for reading (='searching') Association criteria are applicable, it should be noted that these only affect the main level of the search (i.e. the 'left' side of the join). The comparison is therefore not carried out according to the scheme "all association criteria" vs. "all (other) association criteria". Instead, it only checks whether there are any duplicates (alias) for all readable Association criteria with regard to the name. As no access restrictions are taken into account for the alias side of the comparison ('right' in the join), the search may also show duplicates that relate to 'unreadable' Association criteria.

images/download/attachments/167859497/image-2024-1-22_18-3-15-version-1-modificationdate-1705942995169-api-v2.png