如何使用 glassfish 进行延迟属性加载 +顶部链接要点

发布于 2024-08-07 13:26:28 字数 1181 浏览 4 评论 0原文

我有一个查询:

select p from Product p

这给了我期望的结果,但是其中一列(我们称之为 MassiveDescription )很大,并且由于我正在查询完整的产品列表,所以我想排除它。

我将 @Basic(fetch=FetchType.LAZY) 添加到 getMassiveDescription() 但这没有什么区别(生成的 sql 仍然包含所有列)。

我使用的 glassfish 几乎是开箱即用的,它使用了 toplink 的必需品。我认为可能需要做一些事情来配置代理,因此我尝试通过 glassfish Web 界面在 JVM 选项中添加 -javaagent:/path/to/toplink-essentials-agent.jar 。然后我得到一个异常:

java.lang.NoClassDefFoundError: javax/transaction/Synchronization
        at ...

所以我想我需要将 jta.jar 添加到 glassfish Web ui 中的类路径后缀框中。这给了我一个不同的例外:

java.lang.NoClassDefFoundError: oracle/toplink/essentials/transaction/JTASynchronizationListener
        at oracle.toplink.essentials.transaction.JTATransactionController.<init>...

所以现在我正在追逐罐子。我以相同的方式将 toplink-essentials.jar 添加到类路径中,但仍然遇到相同的异常。

我有几个问题:

  • glassfish 是否应该支持开箱即用的延迟属性加载的字节码增强?
  • 如果没有,我是否缺少正确的配置方法?
  • 我读到实现此​​目的的“推荐”方法是使用项目仅选择查询中实体的一部分。我更喜欢这样,但找不到任何有关如何执行此操作的文档。将 select p 替换为 select p.id, p.name, ... 给我带来了奇怪的错误 - 但无论如何我只是猜测语法。

I have a query:

select p from Product p

Which gives me the results I expect, but one of the columns (let's call it massiveDescription) is big, and since I'm querying the full list of products I want to exclude it.

I added @Basic(fetch=FetchType.LAZY) to getMassiveDescription() but this made no difference (the generated sql still includes all columns).

I'm using glassfish pretty much out of the box, and it uses toplink essentials. I thought there might be something I had to do to configure the agent, so I tried adding -javaagent:/path/to/toplink-essentials-agent.jar in the JVM options through the glassfish web interface. Then I get an exception:

java.lang.NoClassDefFoundError: javax/transaction/Synchronization
        at ...

So I figure I need to add jta.jar to the classpath suffix box in the glassfish web ui. That gives me a different exception:

java.lang.NoClassDefFoundError: oracle/toplink/essentials/transaction/JTASynchronizationListener
        at oracle.toplink.essentials.transaction.JTATransactionController.<init>...

So now I'm chasing jars. I add toplink-essentials.jar to the classpath in the same way, but I still get the same exception.

I have a few questions:

  • Is glassfish supposed to support bytecode enhancement for lazy property loading out of the box?
  • If not, am I missing the correct way to configure it?
  • I read that the "recommended" way to achieve this is using a project to select only part of the entity in the query. I like that better, but can't find any documentation on how to do it. Swapping select p for select p.id, p.name, ... gives me strange errors - but I was only guessing at the syntax anyway.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

め七分饶幸 2024-08-14 13:26:28

结果toplink Essentials不支持这个。 Eclipselink 确实如此,所以看起来我正在移动 ORM。

Turns out toplink essentials doesn't support this. Eclipselink does, so looks like I'm moving ORMs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文