From 968753c3c347b9c8875f04bb32989610b353a8ed Mon Sep 17 00:00:00 2001 From: Matthias Schur <107557548+MattSchur@users.noreply.github.com> Date: Mon, 30 Jun 2025 13:10:56 +0200 Subject: [PATCH 1/2] Update Java Query Hints --- java/working-with-cql/query-execution.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/java/working-with-cql/query-execution.md b/java/working-with-cql/query-execution.md index af60b19a2..857f2db9b 100644 --- a/java/working-with-cql/query-execution.md +++ b/java/working-with-cql/query-execution.md @@ -117,15 +117,15 @@ var params = Map.of("minStock", 100); Result result = service.run(query, params); ``` -#### Adding Query Hints for SAP HANA { #hana-hints} +### Query Hints { #query-hints} -To add a hint clause to a statement, use the `hints` method and prefix the [SAP HANA hints](https://help.sap.com/docs/HANA_CLOUD_DATABASE/c1d3f60099654ecfb3fe36ac93c121bb/4ba9edce1f2347a0b9fcda99879c17a1.htmlS) with `hdb.`: +Use the `hints` method to add specific hints to a CDS QL statement. [SAP HANA hints](https://help.sap.com/docs/HANA_CLOUD_DATABASE/c1d3f60099654ecfb3fe36ac93c121bb/4ba9edce1f2347a0b9fcda99879c17a1.htmlS) need to be prefix with `hdb.` ```java -CqnSelect query = Select.from(BOOKS).hints("hdb.USE_HEX_PLAN", "hdb.ESTIMATION_SAMPLES(0)"); +Select.from(BOOKS).hints("hdb.USE_HEX_PLAN", "hdb.HEX_INDEX_JOIN"); ``` -::: warning -Hints prefixed with `hdb.` are directly rendered into SQL for SAP HANA and therefore **must not** contain external input! +::: danger +Hints prefixed with `hdb.` are directly rendered into SQL for SAP HANA and **must not** contain untrusted input! ::: ### Data Manipulation From dfa4a761956f0ff437af69ff55b5cdbcd0b90edc Mon Sep 17 00:00:00 2001 From: Matthias Schur <107557548+MattSchur@users.noreply.github.com> Date: Mon, 30 Jun 2025 13:11:53 +0200 Subject: [PATCH 2/2] Update link --- java/cqn-services/persistence-services.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/cqn-services/persistence-services.md b/java/cqn-services/persistence-services.md index ec2c0250f..025bac5c5 100644 --- a/java/cqn-services/persistence-services.md +++ b/java/cqn-services/persistence-services.md @@ -147,7 +147,7 @@ By default, the SAP HANA adapter in CAP Java generates SQL that is optimized for cds.sql.hana.optimizationMode: legacy ``` -Use the [hints](../working-with-cql/query-execution#hana-hints) `hdb.USE_HEX_PLAN` and `hdb.NO_USE_HEX_PLAN` to overrule the configured optimization mode per statement. +Use the [hints](../working-with-cql/query-execution#query-hints) `hdb.USE_HEX_PLAN` and `hdb.NO_USE_HEX_PLAN` to overrule the configured optimization mode per statement. ::: warning Rare error in `HEX` mode In some corner cases, particularly when using [native HANA views](../../advanced/hana#create-native-sap-hana-objects), queries in `HEX` optimization mode may fail with a "hex enforced but cannot be selected" error. This is the case if the statement execution requires the combination of HEX only features with other features that are not yet supported by the HEX engine. If CAP detects this error it will, as a fallback, execute the query in _legacy_ mode.