Skip to content

Commit 5002237

Browse files
committed
Less text
1 parent 91b2f00 commit 5002237

File tree

1 file changed

+3
-40
lines changed

1 file changed

+3
-40
lines changed

java/working-with-cql/query-api.md

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,12 +1324,7 @@ StructuredTypeRef ref = bookWithId.asRef(); // or CqnStructuredTypeRef which is
13241324

13251325
The method `asRef()` seals the reference and makes it immutable.
13261326

1327-
Relative references point to the elements of the entity, for example, the title of a book, where the type is known in advance or specified elsewhere. In CQL statements, relative references are members of its select list and relate to the statement source that is an absolute reference.
1328-
1329-
```java
1330-
CqnElementRef title = CQL.entity(Books_.class).title(); // {"ref":["title"]}
1331-
CqnElementRef dynamicTitle = CQL.get(Books.TITLE); // {"ref":["title"]}
1332-
```
1327+
Relative references do not specify the type in the first segment and are [element references](/java/working-with-cql/query-api#element-refs) most of the time.
13331328

13341329
New references are constructed with [model interfaces](../cqn-services/persistence-services#model-interfaces) or via API that is also used to build [CQL statements](/java/working-with-cql/query-api#concepts). Prefer model interfaces in the application code.
13351330

@@ -1339,33 +1334,6 @@ References with multiple segments represent navigation within a structured entit
13391334
CqnStructuredTypeRef ref = CQL.entity(Books_.class).filter(b -> b.ID().eq("...")).chapters(c -> c.ID().eq("...")).pages(p -> p.ID().eq("...")).asRef();
13401335
```
13411336

1342-
References have JSON representation that follows an [Expression](../../cds/cxn) notation. Below is the example if it:
1343-
1344-
```json
1345-
{
1346-
"ref": [
1347-
{
1348-
"id": "sap.capire.bookshop.Books",
1349-
"where": [
1350-
{ "ref": ["ID"]}, "=", {"val": "..."}
1351-
]
1352-
},
1353-
{
1354-
"id": "chapters",
1355-
"where": [
1356-
{ "ref": ["ID"]}, "=", {"val": "..."}
1357-
]
1358-
},
1359-
{
1360-
"id": "pages",
1361-
"where": [
1362-
{ "ref": ["ID"]}, "=", {"val": "..."}
1363-
]
1364-
}
1365-
]
1366-
}
1367-
```
1368-
13691337
An existing reference can be reused as an object or a variable, or a new reference can be built on top of it.
13701338

13711339
Given a simple reference pointing to the book created as follows.
@@ -1382,7 +1350,7 @@ You can use `CQL.entity(...)` to cast the reference to the required type and use
13821350
CqnStructuredTypeRef refToAuthor = CQL.entity(Books_.class, ref).author().asRef(); // [!code focus]
13831351
```
13841352

1385-
With `CQL.to(...)` the same is produced dynamically.
1353+
Use `CQL.to(...)` to produce the same dynamically.
13861354

13871355
```java
13881356
// {"ref":[{"id":"sap.capire.bookshop.Books","where":[{"ref":["ID"]},"=",{"val":"..."}]},"author"]}
@@ -1435,17 +1403,12 @@ The references are not comparable between each other. They cannot be used as map
14351403

14361404
### Element References {#element-refs}
14371405

1438-
An element reference points to an element of the entity. Such references are usually _relative_, they do not have the name of the entity in their root. They can include filters in their segments except _in the last one_.
1439-
Most of the time, they exist as members of the [select list](#projections) of a statement or part of the statement, for example, of an expand predicate.
1440-
1441-
The following example illustrates the difference:
1406+
An element reference points to regular element of the entity. Such references are usually _relative_ and form select list for a CQL statement or an expand.
14421407

14431408
```java
14441409
CqnSelect statement = Select.from(Books_.class, b -> b.filter(f -> f.ID().eq("...")))
14451410
.columns(b -> b.author().placeOfBirth());
14461411

1447-
CqnStructuredTypeRef absoluteRef = statement.ref(); // Books(ID=...)
1448-
14491412
CqnElementRef relativeRef = statement.items().getFirst().asRef(); // author/placeOfBirth
14501413
```
14511414

0 commit comments

Comments
 (0)