Hibernate EAGER抓取与级联类型all的区别是什么 [英] What is difference between Hibernate EAGER fetch and cascade-type all

查看:81
本文介绍了Hibernate EAGER抓取与级联类型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.

推荐答案

级联提取是正交的问题.

  1. 级联是关于传播实体状态将Parent实体过渡到Child,通过允许ORM工具代表自己持久/合并/删除依赖关系来简化数据访问代码.

  1. Cascading is about propagating an entity state transition from a Parent entity to a Child, 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆