Hibernate EAGER抓取与级联类型all的区别是什么 [英] What is difference between Hibernate EAGER fetch and cascade-type all
问题描述
请说明休眠的Eager访存与级联类型all的区别.
Please explain difference between hibernate Eager fetching and cascade-type all.
在两种配置中,我们都可以加载与其父级关联的子对象,然后in之间有什么区别.
In both configuration we can load child object associated with its parent, then what is difference between in.
推荐答案
Cascading is about propagating an entity state transition from a
Parent
entity to aChild
, simplifying the data access code by allowing the ORM tool to persist/merge/remove dependent associations on out behalf.
EAGER的获取是映射时关联加载的决定,因为它指示Hibernate每当加载根实体时始终检索依赖的关联.首选查询时间提取,因为它可以为您提供更好的灵活性,同时LAZY提取映射策略可以被FETCH
指令覆盖.使用EAGER
来获取您的卡住了,因为您无法在查询时覆盖它,并且即使在某些用例中您不需要它,Hibernate也将始终获取该关联.
EAGER fetching is a mapping-time association loading decision, because it instructs Hibernate to always retrieve depended associations whenever a root entity gets loaded. Query-time fetching is preferred, because it gives you better flexibility and while the LAZY fetching mapping policy can be overridden by the FETCH
directive. With EAGER
fetching your are stuck, because you can't override it at query time and Hibernate will always fetch the association, even if on some use cases you don't need it.
这篇关于Hibernate EAGER抓取与级联类型all的区别是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!