You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Jean-Baptiste BRIAUD -- Novlog <j-...@novlog.com> on 2010/07/20 10:19:43 UTC

In reply to fetchplan question (was selective columns)

Hi Marc,

Lazy is static in the mapping (either annotation or xml file).
This behavior can be amended at runtime, thanks to fetchplan.
This is why OpenJPA really rocks, because the way to define what we want is dynamic by nature and lazy is a bad answer to that good dynamic need.

This has nothing to do with enhancement.
Enhancement must be done on any entity so it can be managed by OpenJPA.
It is strongly advise, outside small *simple* experiment, to enhance at build-time.

Use find API ot a dead simple request : select from where but no not filter column in the select clause.
Use fetchplan to do that filtering. Add any field you want (basic or not), remove those you don't want (basic or not),
and the request (or call to find) will come back with only what you want, thanks to fetchplan.
Be warned that some attribute will than be null, not because they are null but because they were filtered.
Once null because filtered, they won't come back with just a call to the getter : lazy loading was bypassed by fetchplan.
Fetchplan philosophy is "you know what you need and you come back with that and only that in one shot".
This is opposed to lazy loading where the philosophy is "you don't know what you want and you could ask everytime for something more. This will be done in many request to the database".

To me, lazy loading reveal design issue and lead to bad performance if not more important problems.