views:

284

answers:

1

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

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

Draemon
Draemon, switching from TLE to Eclipselink is super easy, and you won't regret it!
fvu
Not really. GF spat out some fairly confusing messages to begin with. Classloading and policy problems (some of which still aren't sorted). Of course GF3 doesn't have this problem, but I didn't want to switch.
Draemon