title: Exception when trying to use projection for entity with clob type property in spring data
body: <p>There is an entity with CLOB property:</p>
  
  <pre><code>@Entity
  public class Person {
  
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;
  
    private String firstName;
    private String lastName;
  
    @Column(columnDefinition = "clob")
    @Lob
    private String description;
  
    //getters and setters here
  }
  </code></pre>
  
  <p>Now I would like to have a method that can return only part of this class, so here is a projection class:</p>
  
  <pre><code>public interface PersonProjection {
    String getLastName();
    String getDescription();
  }
  </code></pre>
  
  <p>and the repository:</p>
  
  <pre><code>@Repository
  public interface PersonRepository extends PagingAndSortingRepository&lt;Person, Long&gt; {
  
    @Query(value = "select pe.last_name as lastName, pe.description from person pe where pe.last_name = :lastName", nativeQuery = true)
    List&lt;PersonProjection&gt; findAllByLastName(@Param("lastName") String lastName);
  }
  </code></pre>
  
  <p>Using native query in this example is not needed but in my case I would like to call an Oracle's function in the <code>where</code> clause (<code>JSON_TEXTCONTAINS</code> to be specific). </p>
  
  <p>Now using this repository in the controller causes:</p>
  
  <pre><code>Could not write JSON: Projection type must be an interface!; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Projection type must be an interface! (through reference chain: java.util.ArrayList[0]-&gt;com.sun.proxy.$Proxy103[\"description\"])
  </code></pre>
  
  <p>Exception seems to be caused because query returns <code>description</code> field as an instance of <code>java.sql.Clob</code> interface, but in projection class this field is defined as <code>String</code>. Exception is not thrown when entity class is used as a return type from repository method (and there <code>description</code> is also defined as a <code>String</code>).</p>
  
  <p>Complete project to check this problem can be found <a href="https://github.com/piotrchowaniec/clob-native-projection" rel="nofollow noreferrer">here</a>.</p>