Get objects with a list in JPA native query

Viewed 33

I have a native query that return list of objects, and inside every object an attribute of type list :

Child interface :

public interface ChildInterface {
    public Integer getId();
    public String getCode();
    public String getLabel();
}

Example interface :

public interface ExampleInterface {
    public Integer getId();
    public String getLabel();
    public List<ChildInterface> getChildren();
}

I need to create a native query to get Example list with there Children :

@Query(nativeQuery = true, value = "select e.id as id from example e .....")
List<ExampleInterface> search()

Tables:

Example: id, label

Child: id, code, label, example_id

0 Answers
Related