dongxun1142 2015-07-02 10:26
浏览 69
已采纳

延迟加载实体的Doctrine Repository机制如何工作?

So, I want to understand how the Doctrine Repository mechanism works.

For my entities I use annotations, so the resulting object is built somewhere during the execution of the script.

I'd like to unserstand which are the possibile ways of implementing the lazy loading of entities from another entity.

In concrete, using Doctrine, I have the ability to fetch information of related object (from the Symfony book). This fetching is done in a lazy way: only if I call the method to get the information about the Entity it is loaded from the database querying it.

Now, I'd like to better understand this mechanism: how an entity can implement repository methods? How can I reproduce this mechanism to implement it in other context similar to the one of a database data retrieval?

As the resulting object is really big, is there someone who can put me on the right way? Which classes should have I read to understand the mechanism? Are there any articles/posts that better explain how this mechanism is implemented? Are there better (or simply simpler) ways of implementing it?

  • 写回答

3条回答 默认 最新

  • dtw52353 2015-07-17 10:42
    关注

    I think the best description of the lazy loading can be found in Doctrine developer articles. http://www.giorgiosironi.com/2009/07/lazy-loading-of-objects-from-database.html http://www.giorgiosironi.com/2009/08/doctrine-2-now-has-lazy-loading.html

    The main idea is to insert into Product's category list a set of objectes that are subclasses of Category. These and called "proxy objects" and created "on the fly" when Product is retrieved from database. These proxy objects have the same interface as Category object, but add functionality of loading actual Category items from database when needed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化