Hibernate default joining for nullable many-to-one

前端 未结 1 1426
有刺的猬
有刺的猬 2021-01-11 09:43

I have a hibernate mapping like this in a ProductDfn class

@ManyToOne( fetch = FetchType.LAZY, optional = true )
@JoinColumn( name = \"productTypeFk\", nulla         


        
相关标签:
1条回答
  • 2021-01-11 10:15

    An inner join is used because you've explicitly listed p.productType.name in your select clause. This wouldn't have happened were you just to select ProductDfn since your fetch is set to LAZY.

    If you only need to retrieve those two properties you'll have to explicitly specify an outer join in your query:

    select p.name as col1, ptype.name as col2
      from ProductDfn p
      left join fetch p.productType ptype
    
    0 讨论(0)
提交回复
热议问题