Hello group,
I really don't get the idea of "lazy loading". From the Castor site I read the
following:
"Per definition, when an instance of Department is loaded through e.g.
Database.load(), Castor will not (pre-)load the Employee instance referenced
(as such reducing the size pf the initial query as well as the size of the
result set returned). Only when the Emplyoee instance is accessed through
Department.getEmployee(), Castor will load the actual object into memory from
the persistence store.
This means that if the Employee instance is not accessed at all, not only will
the initial query to load the Department object have had its complexity
reduced, but no performance penalty will be incurred for the additional access
to the persistence store either."
As a consequence, I would have expected that a lazy object if never accessed,
will never be loaded into memory. This seems to not be the case. A code like
the following:
Database db = _jdo.getDatabase();
db.begin();
OQLQuery query = db.getOQLQuery("SELECT product FROM " +
Product.class.getName() + " product WHERE id = $1");
query.bind(new Integer(1));
QueryResults results =
query.execute(AccessMode.ReadOnly);
Product product = (Product) results.next();
db.commit();
db.close();
will load all the lazy mappings from the Product class (1:1 or whatever) during
the commit() phase.
Am I getting something wrong, or is it by design so?
Thanks a lot,
JC