Setting FetchMode in native Hibernate

前端 未结 3 1367
长情又很酷
长情又很酷 2021-01-14 00:46

I need to set the fetch mode on my hibernate mappings to be eager in some cases, and lazy in others. I have my default (set through the hbm file) as lazy=\"true\". How do I

3条回答
  •  不要未来只要你来
    2021-01-14 01:16

    If you're not using Criteria there's also the JOIN FETCH keyword that will eagerly load the association specified by the join.

    session.createQuery("select p from Parent p join fetch p.children c")
    

提交回复
热议问题