4.5.3.2.1. Returned values

A query should return entities of the type which is specified at the moment of creating a data source. In case of declarative creation, the entity type is specified in the class attribute of an XML element, if DsBuilder is used – in the setJavaClass() or setMetaClass() method.

Furthermore, the object type in the from query statement should match the source type. This is necessary for automatic query transformations if security limitations, etc. are applied.

For example, a query of the data source of the Customer type may look as follows:

select c from sales$Customer c

Below are examples of invalid queries for a source of the Customer type:

select c.id, c.name from sales$Customer c /* invalid – returns single fields, not the whole Customer object */

select o.customer from sales$Order o /* invalid – the 'from' type (Order) is different from the resulting type  (Customer) */