title: Spring data jpa - the best way to return object?
body: <p>I have object like this:</p>
  
  <pre><code>@Entity
  public class DocumentationRecord {
      @Id
      @GeneratedValue
      private long id;
  
      private String topic;
      private boolean isParent;
      @OneToMany
      private List&lt;DocumentationRecord&gt; children;
  ...
  }
  </code></pre>
  
  <p>now I would like to get only topics and ids. Is there way to get it in format like this:</p>
  
  <pre><code>[
  {
  id: 4234234,
  topic: "fsdfsdf"
  },...
  ]
  </code></pre>
  
  <p>Because even using only this query </p>
  
  <pre><code>public interface DocumentationRecordRepository extends CrudRepository&lt;DocumentationRecord, Long&gt; {
  
      @Query("SELECT d.topic as topic, d.id as id FROM DocumentationRecord d")
      List&lt;DocumentationRecord&gt; getAllTopics();
  }
  </code></pre>
  
  <p>I was only able to get record like this:</p>
  
  <pre><code>[
    [
      "youngChild topic",
      317
    ],
    [
      "oldChild topic",
      318
    ],
    [
      "child topic",
      319
    ],
  ]
  </code></pre>
  
  <p>I don't like array of arrays I would like to get array of object with property id and topic. What is the nicest way to achieve that?</p>