JPA和eclipselink-覆盖FetchType.Eager [英] JPA and eclipselink - Overriding FetchType.Eager

查看:98
本文介绍了JPA和eclipselink-覆盖FetchType.Eager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堂课,其中一些成员带有注释:

I have a class where a few members have annotation:

@ManyToOne(fetch = FetchType.EAGER)

在我程序的特定部分,这些加载了太多的数据.不幸的是,我无法更改这些注释,因为这会影响该程序其他部分的性能. eclipselink中是否可以将1个特定的JPQL查询更改为LAZY?

In the specific part of my program, these load far too many data. Unfortunately, I can't change these annotations as this will influence performance of other parts of this program. Is there a way in eclipselink to change this to LAZY for 1 specific JPQL query?

要用另一种方式表示,您可以通过使用访存联接将LAZY更改为EAGER.我希望能将EAGER更改为LAZY

To phrase this an other way, you can change LAZY to EAGER by using a fetch join. I'm hoping for something which changes EAGER to LAZY

推荐答案

这是不可能的.我的经验法则是:使所有内容都变得懒散,并且如果您想快速获取,请使用自定义查询.

It's not possible. My rule of thumb is : make everything LAZY, and use custom queries if you want eager fetching.

您最好的办法是加载元组(并填充DTO),而不是加载实体.

The best you can do is to load tuples (and populate DTOs) instead of loading entities.

这篇关于JPA和eclipselink-覆盖FetchType.Eager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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