title: How to insert CLOB to Oracle using Spring Data
body: <p>I have problem with trying to save CLOB to Oracle using Spring Data and CRUDRepository interface. On the database side, column is of CLOB type. Strings shorter than 4000 characters are saved correctly, but longer - not (ORA-01461), despite the @Lob annotation and column definition parameter in @Column annotation. I couldn't find solution for this issue, because all I found relates to Spring JDBC Template, not Spring Data.</p>
  
  <pre><code>try (ByteArrayInputStream inputStream = new ByteArrayInputStream(messageBody.getBytes(StandardCharsets.UTF_8))) {
          message = (DeadLetterMessage) unmarshaller.unmarshal(new StreamSource(inputStream));
      }
  
      try {
          message = repository.save(message);
      } catch (Throwable e) {
          log.warn("### Failed to store message in database", e);
          throw e;
      }
  </code></pre>
  
  <p>Properties in persistence.xml:</p>
  
  <pre><code>&lt;persistence-unit name="deadletter" transaction-type="RESOURCE_LOCAL"&gt;
      &lt;provider&gt;org.hibernate.jpa.HibernatePersistenceProvider&lt;/provider&gt;
      &lt;class&gt;com.lppsa.integration.camel.dlc.entity.DeadLetterMessage&lt;/class&gt;
      &lt;properties&gt;
          &lt;property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/&gt;
          &lt;property name="hibernate.connection.SetBigStringTryClob" value="true"/&gt;
          &lt;property name="hibernate.jdbc.batch_size" value="true"/&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p>Problem is only with values longer than 4000.</p>
  
  <pre><code>(...)
  @Lob
  @Basic(fetch = FetchType.LAZY)
  @Column(name = "MESSAGE_DATA", columnDefinition = "CLOB NOT NULL")
  @XmlJavaTypeAdapter(ByteArrayXmlAdapter.class)
  private byte[] messageData;
  (...)
  </code></pre>