Ich habe Objekt wie folgt:Spring Daten jpa - der beste Weg, um ein Objekt zurückzugeben?
@Entity
public class DocumentationRecord {
@Id
@GeneratedValue
private long id;
private String topic;
private boolean isParent;
@OneToMany
private List<DocumentationRecord> children;
...
}
jetzt würde Ich mag nur Themen und IDs erhalten. Gibt es so, wie es in Format wie folgt zu erhalten:
[
{
id: 4234234,
topic: "fsdfsdf"
},...
]
Denn auch nur diese Abfrage mit
public interface DocumentationRecordRepository extends CrudRepository<DocumentationRecord, Long> {
@Query("SELECT d.topic as topic, d.id as id FROM DocumentationRecord d")
List<DocumentationRecord> getAllTopics();
}
Ich konnte nur Datensatz wie folgt erhalten:
[
[
"youngChild topic",
317
],
[
"oldChild topic",
318
],
[
"child topic",
319
],
]
I don Ich möchte Array von Arrays Ich möchte Array von Objekt mit Eigenschaften-ID und Thema erhalten. Was ist der beste Weg, um das zu erreichen?