[Java] Document references#2153
Conversation
|
Hi @vmikhailenko , |
Co-authored-by: René Jeglinsky <rene.jeglinsky@sap.com>
Co-authored-by: René Jeglinsky <rene.jeglinsky@sap.com>
… into java-document-refs
renejeglinsky
left a comment
There was a problem hiding this comment.
I guess it's ok to simplify the links like that. Or have you had a certain reason not to do it?
|
|
||
| The method `asRef()` seals the reference and makes it immutable. | ||
|
|
||
| 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. |
There was a problem hiding this comment.
| 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. | |
| Relative references do not specify the type in the first segment and are [element references](#element-refs) most of the time. |
|
|
||
| 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. | ||
|
|
||
| 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. |
There was a problem hiding this comment.
| 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. | |
| New references are constructed with [model interfaces](../cqn-services/persistence-services#model-interfaces) or via API that is also used to build [CQL statements](#concepts). Prefer model interfaces in the application code. |
| CqnElementRef relativeRef = statement.items().getFirst().asRef(); // author/placeOfBirth | ||
| ``` | ||
|
|
||
| Element references can be extended with the same APIs as the entity references. |
There was a problem hiding this comment.
| Element references can be extended with the same APIs as the entity references. | |
| Element references can be extended with the same APIs as the [entity references](#entity-refs). |
|
Go ahead. I am also OK with textual changes. |
|
|
||
| You can also get [entity references](query-execution#entity-refs) from the result of a CDS QL statement to address an entity via its key values in other statements. | ||
|
|
||
| Each reference has ordered sequence of _segments_ that define the path from the entity's root to the certain part of it. Segment has the _identifier_ with the name of the entity or an element and optional filter _predicate_. |
There was a problem hiding this comment.
| Each reference has ordered sequence of _segments_ that define the path from the entity's root to the certain part of it. Segment has the _identifier_ with the name of the entity or an element and optional filter _predicate_. | |
| Each reference has ordered sequence of _segments_ that defines the path from the entity's root to the certain part of it. Segment has the _identifier_ with the name of the entity or an element and optional filter _predicate_. |
|
|
||
| Each reference has ordered sequence of _segments_ that define the path from the entity's root to the certain part of it. Segment has the _identifier_ with the name of the entity or an element and optional filter _predicate_. | ||
|
|
||
| Existing reference can be reused as an object or a variable, or a new reference can be built on top of it. References are not bound to the particular model and are not checked against it while they are being built. |
There was a problem hiding this comment.
| Existing reference can be reused as an object or a variable, or a new reference can be built on top of it. References are not bound to the particular model and are not checked against it while they are being built. | |
| An existing reference can be reused as an object or a variable, or a new reference can be built on top of it. References are not bound to the particular model and are not checked against it while they are being built. |
|
|
||
| Existing reference can be reused as an object or a variable, or a new reference can be built on top of it. References are not bound to the particular model and are not checked against it while they are being built. | ||
|
|
||
| References can be _absolute_ or _relative_. Absolute reference has fully qualified entity name as the identifier in the first segment. They usually have associations as their segments. |
There was a problem hiding this comment.
| References can be _absolute_ or _relative_. Absolute reference has fully qualified entity name as the identifier in the first segment. They usually have associations as their segments. | |
| References can be _absolute_ or _relative_. An absolute reference has a fully qualified entity name as the identifier in the first segment. They usually have associations as their segments. |
|
|
||
| References can be _absolute_ or _relative_. Absolute reference has fully qualified entity name as the identifier in the first segment. They usually have associations as their segments. | ||
|
|
||
| You start with the reference pointing to a book with certain key. You build it using corresponding [model interfaces](../cqn-services/persistence-services#model-interfaces) providing you the methods that corresponds to the elements of the book. |
There was a problem hiding this comment.
| You start with the reference pointing to a book with certain key. You build it using corresponding [model interfaces](../cqn-services/persistence-services#model-interfaces) providing you the methods that corresponds to the elements of the book. | |
| You start with the reference pointing to a book with a certain key. You build it using corresponding [model interfaces](../cqn-services/persistence-services#model-interfaces) providing you the methods that corresponds to the elements of the book. |
| refToAuthor.segments().subList(0, refToAuthor.segments().size() - 1)).asRef(); // Books(ID=...) | ||
| ``` | ||
|
|
||
| You can also construct ref that starts from the first segment to navigate to different path of the same root. |
There was a problem hiding this comment.
| You can also construct ref that starts from the first segment to navigate to different path of the same root. | |
| You can also construct a ref that starts from the first segment to navigate to different path of the same root. |
|
Do we need this? |
|
Should we finish this or is this obsolete meanwhile? |
The application developers are now exposed to the concept of references via arguments of custom handlers.
They should now what these are and how you supposed to work with them.
We can also improve the APIs a bit as some of these look rather ugly.