Hibernate Native SQL Query retrieving entities and collections

前端 未结 5 1646
谎友^
谎友^ 2020-12-13 06:54

This is my situation, I have two basic POJO\'s which I\'ve given a simple hibernate mapping :

Person
  - PersonId
  - Name
  - Books

Book
  - Code
  - Descr         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 07:35

    Should your query be on the person table instead of person_books?

    session.createSQLQuery("select * from person")  
       .addEntity("person", Person.class)
       .addJoin("book", "person.books")
       .list();
    

提交回复
热议问题