Hi,
My problem may be a new idea, but here's what I'd like to do.
Is there any way to do some "parametric load on demand".
In fact, I'd like to annotate some fields (that can be huge) with something like
public class Example {
@LoadWhen(param=[1,2])
private Object field1;
@LoadWhen(param=[1])
private Object field2;
@LoadWhen(param=[2])
private Object field3;
...
}
And when I want to get the Example classes :
** A call to session.createQuery("from Example",[1,2]) will load every Example Object fetching only 'field1'
** A call to session.createQuery("from Example",[1]) will load every Example Object fetching only 'field1' and 'field2'
** A call to session.createQuery("from Example",[2]) will load every Example Object fetching only 'field1' and 'field3'
(The fields that are not fetched can keep default value for primitive types and null for others.
I think it's the best way to manage on demand loading. If you know a better or existing way to do the same, thanks in advance.
JL.
|