<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: CAP Java:  Handle $count query in Custom Handler in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/cap-java-handle-count-query-in-custom-handler/qaa-p/12792474#M4802956</link>
    <description>&lt;P&gt;I opened a PR to improve this in our docs: &lt;A href="https://github.com/cap-js/docs/pull/495" target="test_blank"&gt;https://github.com/cap-js/docs/pull/495&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Oct 2023 14:22:36 GMT</pubDate>
    <dc:creator>marcbecker</dc:creator>
    <dc:date>2023-10-23T14:22:36Z</dc:date>
    <item>
      <title>CAP Java:  Handle $count query in Custom Handler</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-handle-count-query-in-custom-handler/qaq-p/12792469</link>
      <description>&lt;P&gt;Hello community,&lt;/P&gt;
  &lt;P&gt;we are using CAP Java and want to use the &lt;STRONG&gt;$count&lt;/STRONG&gt; query in a custom handler:&lt;/P&gt;
  &lt;P&gt;Query:&lt;BR /&gt;&lt;STRONG&gt;&lt;A href="http://localhost:8080/api/play/Books/$count" target="test_blank"&gt;http://localhost:8080/api/play/Books/$count&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2215676-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;We are using the &lt;STRONG&gt;CqnAnalyzer&lt;/STRONG&gt; to check if this is a $count query or not. Normally we return a list of Books but we don't know, how we can return the response for a $count query.&lt;/P&gt;
  &lt;P&gt;If we return the List of Books as well we are getting the error:&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2215667-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;So what is the correct way to return the result for $count?&lt;BR /&gt;In the documentation I just found how to pass the &lt;STRONG&gt;inlinecount &lt;/STRONG&gt;by using the &lt;A href="https://cap.cloud.sap/docs/java/application-services#result-builder"&gt;ResultBuilder&lt;/A&gt;.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;Result r = selectedRows(asList(row)).inlineCount(inlineCount).result();&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; &lt;BR /&gt;Best regards and many thanks, &lt;BR /&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 05:41:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-handle-count-query-in-custom-handler/qaq-p/12792469</guid>
      <dc:creator>christoffer_fuss</dc:creator>
      <dc:date>2023-10-11T05:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: CAP Java:  Handle $count query in Custom Handler</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-handle-count-query-in-custom-handler/qaa-p/12792470#M4802952</link>
      <description>&lt;P&gt;It seems that the formatting of the code block of your handler is lost. Could you please edit the post? Thx! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 06:41:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-handle-count-query-in-custom-handler/qaa-p/12792470#M4802952</guid>
      <dc:creator>robinjayasinghe</dc:creator>
      <dc:date>2023-10-11T06:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: CAP Java:  Handle $count query in Custom Handler</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-handle-count-query-in-custom-handler/qaa-p/12792471#M4802953</link>
      <description>&lt;P&gt;Sry for that but posting code seems to be broken, so I used a picture instead.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 07:18:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-handle-count-query-in-custom-handler/qaa-p/12792471#M4802953</guid>
      <dc:creator>christoffer_fuss</dc:creator>
      <dc:date>2023-10-11T07:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: CAP Java:  Handle $count query in Custom Handler</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-handle-count-query-in-custom-handler/qaa-p/12792472#M4802954</link>
      <description>&lt;P&gt;The $count query from OData is done by sending a CqnSelect containing only a count(*) function with alias count. Therefore the expected result structure would be something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Arrays.asList(Collections.singletonMap("count", value));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can adapt your method signature to use return type List&amp;lt;Map&amp;lt;String, Object&amp;gt;&amp;gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 07:27:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-handle-count-query-in-custom-handler/qaa-p/12792472#M4802954</guid>
      <dc:creator>marcbecker</dc:creator>
      <dc:date>2023-10-11T07:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: CAP Java:  Handle $count query in Custom Handler</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-handle-count-query-in-custom-handler/qaa-p/12792473#M4802955</link>
      <description>&lt;P&gt;Thanks Marc, it works fine &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Maybe you can add this in the documentation as well.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 11:35:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-handle-count-query-in-custom-handler/qaa-p/12792473#M4802955</guid>
      <dc:creator>christoffer_fuss</dc:creator>
      <dc:date>2023-10-11T11:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: CAP Java:  Handle $count query in Custom Handler</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-handle-count-query-in-custom-handler/qaa-p/12792474#M4802956</link>
      <description>&lt;P&gt;I opened a PR to improve this in our docs: &lt;A href="https://github.com/cap-js/docs/pull/495" target="test_blank"&gt;https://github.com/cap-js/docs/pull/495&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 14:22:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-handle-count-query-in-custom-handler/qaa-p/12792474#M4802956</guid>
      <dc:creator>marcbecker</dc:creator>
      <dc:date>2023-10-23T14:22:36Z</dc:date>
    </item>
  </channel>
</rss>

