Skip to content

[Java] Document references#2153

Open
vmikhailenko wants to merge 25 commits into
mainfrom
java-document-refs
Open

[Java] Document references#2153
vmikhailenko wants to merge 25 commits into
mainfrom
java-document-refs

Conversation

@vmikhailenko

Copy link
Copy Markdown
Contributor

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.

Comment thread java/working-with-cql/query-api.md Outdated
Comment thread java/working-with-cql/query-api.md Outdated
@renejeglinsky renejeglinsky added the AI Review AI generated suggestions label Nov 5, 2025
github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

@renejeglinsky

Copy link
Copy Markdown
Contributor

Hi @vmikhailenko ,
I enabled an AI editing workflow and would like to collect your feedback on the current suggestions. Please go through the suggestions and apply the ones you deem helpful. Afterwards please send me a little feedback/summary of what you think it does good and what you didn't like. Thank you :)

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

Co-authored-by: René Jeglinsky <rene.jeglinsky@sap.com>
github-actions[bot]

This comment was marked as outdated.

Co-authored-by: René Jeglinsky <rene.jeglinsky@sap.com>
github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

@renejeglinsky renejeglinsky removed the AI Review AI generated suggestions label Nov 6, 2025

@renejeglinsky renejeglinsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's ok to simplify the links like that. Or have you had a certain reason not to do it?

Comment thread java/working-with-cql/query-api.md Outdated

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment thread java/working-with-cql/query-api.md Outdated

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment thread java/working-with-cql/query-api.md Outdated
CqnElementRef relativeRef = statement.items().getFirst().asRef(); // author/placeOfBirth
```

Element references can be extended with the same APIs as the entity references.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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).

Comment thread java/working-with-cql/query-api.md Outdated
@vmikhailenko

Copy link
Copy Markdown
Contributor Author

Go ahead. I am also OK with textual changes.

Comment thread java/working-with-cql/query-api.md Outdated

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_.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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_.

Comment thread java/working-with-cql/query-api.md Outdated

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment thread java/working-with-cql/query-api.md Outdated

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment thread java/working-with-cql/query-api.md Outdated

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment thread java/working-with-cql/query-api.md Outdated
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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@vmikhailenko

Copy link
Copy Markdown
Contributor Author

Do we need this?

@renejeglinsky

Copy link
Copy Markdown
Contributor

Should we finish this or is this obsolete meanwhile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants