简体   繁体   中英

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 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM