开发者

How to use lazy property loading with glassfish + toplink essentials

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 t开发者_开发问答he 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜