Why Hibernate sometimes ignores FetchMode.JOIN?

后端 未结 1 965
旧巷少年郎
旧巷少年郎 2021-01-12 10:49

I have an entity with a @ManyToOne relation, which I\'d like to retrieve with a single query, thus using @Fetch(FetchMode.JOIN). Sometimes Hibernat

相关标签:
1条回答
  • 2021-01-12 11:24

    The rule is quite simple: Queries ignore fetch modes. When you write a query, you are telling what is joined and what is not joined.

    Fetch mode is only taken into account when entity is loaded with methods like EntityManager.find(class, id) or when navigating through some other entity graph and loading its associations.

    0 讨论(0)
提交回复
热议问题