<?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: Reading LargeBinary from HANA DB as InputStream bigger than 1024 Bytes in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/cap-java-reading-largebinary-from-hana-db-as-inputstream-bigger-than-1024/qaa-p/12793432#M4803319</link>
    <description>&lt;P&gt;Hi Marc, thanks for the fast answer. Yes the query is executed in a background job by the persistenceService without using an explicit ChangeSetContext. We will give it a try and let you know if it is working &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Wed, 11 Oct 2023 15:23:29 GMT</pubDate>
    <dc:creator>christoffer_fuss</dc:creator>
    <dc:date>2023-10-11T15:23:29Z</dc:date>
    <item>
      <title>CAP JAVA: Reading LargeBinary from HANA DB as InputStream bigger than 1024 Bytes</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-reading-largebinary-from-hana-db-as-inputstream-bigger-than-1024/qaq-p/12793430</link>
      <description>&lt;P&gt;Hi community,&lt;/P&gt;
  &lt;P&gt;we have a custom handler in CAP Java where we want to read a CDS entity with a property of type LargeBinary&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2215700-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt; This LargeBinary property is mapped in Java to type InputStream&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2215701-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;When we use the method &lt;STRONG&gt;getContent&lt;/STRONG&gt; to read the InputStream we are getting an exception and InputStream is null if the file is &lt;STRONG&gt;bigger than 1024 bytes&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/2215702-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;We are getting this error message:&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2215703-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;This only happens with HANA DB, with SQLITE it is working fine. If we check the content n SAP HANA Database Explorer the content is full available.&lt;/P&gt;
  &lt;P&gt;So what is the correct way to read a LargeBinaray (BLOB in HANA) with CAP JAVA?&lt;/P&gt;
  &lt;P&gt;Best regards and many thanks,&lt;/P&gt;
  &lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 14:19:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-reading-largebinary-from-hana-db-as-inputstream-bigger-than-1024/qaq-p/12793430</guid>
      <dc:creator>christoffer_fuss</dc:creator>
      <dc:date>2023-10-11T14:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: CAP JAVA: Reading LargeBinary from HANA DB as InputStream bigger than 1024 Bytes</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-reading-largebinary-from-hana-db-as-inputstream-bigger-than-1024/qaa-p/12793431#M4803318</link>
      <description>&lt;P&gt;How do you execute the CqnSelect that returns you the book entity? You need to ensure that you retrieve the content InputStream within the active transaction. If there is no explicit transaction boundary opened around your code (e.g. in a background thread or custom RestController), you might need to open an explicit ChangeSetContext. This would look like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;runtime.changeSetContext().run(changeSet -&amp;gt; {&lt;BR /&gt;  Books book = service.run(Select.from(...)).single(Books.class);&lt;BR /&gt;  InputStream content = book.getContent();&lt;BR /&gt;  // make sure to consume the InputStream within the active transaction&lt;BR /&gt;  // otherwise transaction is committed in HANA and connection returned to the pool&lt;BR /&gt;  // which frees the resources not yet streamed&lt;BR /&gt;}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you execute that code as part of an OData request coming from CAPs OData adapters the ChangeSetContext and transactional boundary should be there already by default.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 15:04:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-reading-largebinary-from-hana-db-as-inputstream-bigger-than-1024/qaa-p/12793431#M4803318</guid>
      <dc:creator>marcbecker</dc:creator>
      <dc:date>2023-10-11T15:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: CAP JAVA: Reading LargeBinary from HANA DB as InputStream bigger than 1024 Bytes</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-reading-largebinary-from-hana-db-as-inputstream-bigger-than-1024/qaa-p/12793432#M4803319</link>
      <description>&lt;P&gt;Hi Marc, thanks for the fast answer. Yes the query is executed in a background job by the persistenceService without using an explicit ChangeSetContext. We will give it a try and let you know if it is working &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 15:23:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-reading-largebinary-from-hana-db-as-inputstream-bigger-than-1024/qaa-p/12793432#M4803319</guid>
      <dc:creator>christoffer_fuss</dc:creator>
      <dc:date>2023-10-11T15:23:29Z</dc:date>
    </item>
  </channel>
</rss>

