Hibernate - HQL to fetch a collection from Unidirectional OneToMany relationship

后端 未结 2 1302
自闭症患者
自闭症患者 2021-02-08 23:14

I have an Class with a unidirectional one to many relationship as follows:

public class Order {
    @OneToMany(cascade = CascadeType.ALL)
    @JoinTable(name=\"o         


        
2条回答
  •  忘掉有多难
    2021-02-08 23:41

    select item from Order order
    inner join order.items item
    where order = :order
    and ...
    

    HQL queries use entities and their associations. The fact that the association uses a join table or not is not important for HQL: you navigate through associations and Hibernate does the appropriate translation to SQL.

提交回复
热议问题