0

I have a fairly simple problem. I need to get likeness a tree from the result of the stored procedure. But unfortunately all the examples I've found, used or tables, or uniform structure of the tree.

Stored procedure can return:

| firm_id | index_id | value |
|    1    |    101   |  123  |
|    1    |    102   |  123  |
|    2    |    101   |  123  |

I'm trying to divide by class:

@Entity
@NamedNativeQuery(
    name = "getReport",   
    resultClass = Report.class,   
    query = "{call myProc(?)}",
    callable = true
)
public class Report {
    @Id
    @Column(name = "firm_id")
    private long firmId;
    @Embedded
    private List<Index> indexList;

   // getters and setters
}

Second class:

@Embeddable
public class Index {
    @Column(name = "index_id")
    private long indexId;
    @Column(name = "value")
    private int value;

    // getters and setters
}

As a result I get a null. I also tried using @ManyToOne/@OneToMany, but received "Table not found". What am I doing wrong?

Thank you for your attention.

Mike
  • 33
  • 5
  • Could [`@DiscriminatorValue`](http://docs.oracle.com/javaee/6/api/javax/persistence/DiscriminatorValue.html) be what you are looking for? This question may help: [Hibernate mapping multiple classes to one table using hbm.xml](http://stackoverflow.com/questions/8738761/hibernate-mapping-multiple-classes-to-one-table-using-hbm-xml). – Mr. Polywhirl Oct 15 '13 at 10:20
  • Mr. Polywhirl, Thanks for the advice. But based on [this](http://stackoverflow.com/questions/16772370/when-to-use-discriminatorvalue-annotation-in-hibernate) this solution is not quite right for me. My classes are not in the same hierarchy. I changed the title of the issue, in order to make it more understandable. – Mike Oct 15 '13 at 10:52

0 Answers0