max wrote:
don't have a better suggestion for you regarding 2.1.x - your own solution is ok.
Ok, let's do that then. Thanks. Can we imagine to have the method getNamedQuery accessible in SessionFactory? (I know that in Hibernate 3 the method doesn't return a String anymore) Even with the filter it might be useful sometime no?
max wrote:
to do real lazy property loading we need to instrument at build time (or classloading time). If i remember correctly the resaon for this is to allow you to use your own new'ed objects.
Doh... Right, didn't thought about that. Good reason.
max wrote:
what do you mean with many-to-one relationship not being lazy ? If the class on the one side is a proxy'able/lazy'able it will not be loaded from the db before you access it.
I mean lazy loading by usage. Let's say I have a class A. There's a many-to-one association from B to A and also from C to A.
The process manipulating B rarely use A. So I want it lazy. On the other side, the process using C almost need it everytime. I want to keep lazy false. I can't since the lazy is set on A, not on the associations.
Possibly I can put an outer-join="true" on C to patch that. But I prefer not to since I'm using level 2 caching and I don't want to do a select on table A since I probably already have the A instance in my cache.
That's why I would have want it. But in fact basically, it's beacause I want to ask myself the following question:
- Do I need to load this associated object often?
when thinking about putting lazy="true" somewhere instead of:
- Do all the classes having an association with this class benefit of having it lazy?
In the later case, I need to know the complete graph of dependencies. I also need to do regression testing all over the place to make sure I didn't broke any code using the newly lazy class.