Entity Services
A business object used to save and permit access to application data.
You use entity services to define attributes and data types to generate database tables and define DB table relations, and implement basic methods for reading, writing, updating, deleting, and querying data. An entity service is a clearly identifiable unit.
Entity services refer to a model for entity service instances. It can be persisted locally or in a back-end SAP system. By using entity services, you take advantage of the flexibility in accessing and mixing all types of data from remote and local persistency. For more information about persistency, Service Persistency.
Of all the services used for creating composite applications, entity services are unique in that you can model attributes and use services that are predelivered with the CAF library.
You model attributes and attribute properties for an entity service with the Attributes tab page with the Composite Application Services plug-in to SAP NetWeaver Developer Studio. You can create the following type of attributes:
● Simple attributes
● Complex attributes and their subattributes
● Relations to other entity services
Simple data types are general data fields and correspond to a column in a table. They are classified by their numeric or alphanumeric qualities. In an entity service, a simple attribute refers to the field in an entity service table.
Simple attributes can consist of, for example, string, integer, or real data types and can be language or time dependent. In the case of language dependent texts, a simple type also represents a text table.
Default attributes are automatically created when you create an entity service. The standard attributes are simple attributes and cannot be changed or deleted. They are:
● key
● createdAt
● createdBy
● lastChangedAt
● lastChangedBy

Simple attributes can have a cardinality of 0..1 and 0..n or 1..1 and 1..n. assuming they were defined as mandatory attributes. A cardinality of 0..n or 1..n means that an additional table is created in the database with a primary key and an attribute.
Complex attributes are groups of simple types that are part of an entity service and contain more data fields. On a database level, complex types own a table. You use complex attributes to structure an entity service. A complex attribute is accessed indirectly per pointer via the corresponding entity service.
Complex attributes cannot be shared between entity services. They refer to one entity service only. If you delete the entity service instance, the referenced instance of the complex type is also deleted. You cannot define complex attributes as language dependent or mandatory.
Subattributes can only be simple attributes and cannot be mandatory (not be set to “true”). They also can have a cardinality of 0..1.
You can create relations between entity services, but not between complex types of different entity services. Relations are represented as attributes.
A relation can also be a collection. Relations between entity services can only be unidirectional; however there can be 0..1 and 0..n relationships.
Associations are the only type of relations supported. If an object is deleted, the associated objects are not deleted.
The following restrictions apply for relations between entity services:
● Relations between entity services can only be unidirectional. A bidirectional relation has to be modeled as two unidirectional relations.
● Entity services can only refer to (relations and inheritance):
○ Other entity services of the same project
○ Core entity services
● Entity services can only reference other entity services.

These rules are handled by the service modeling tool of CAS.
A relation between two entity services is not mapped to a foreign-key relation on database level. A referenced entity service is always accessed by using the getRelationNamemethod by using this GUID to call the read method on the referenced entity service bean.
You can use predefined and commonly used services to create your composite application. These services included in the CAF core project and delivered with the CAF library are referred to as core services and are commonly used entities that span across an entire application.
For information about the services and data types delivered with the CAF library, see Composite Application Services and Data Types.
Designing Services in CAF Core → Service Modeling → Modeling Entity Services