Also one other thing, even if you get all that right, you still have the
problem of efficiently loading the dependent objects too and related objects
if you know you are going to need them.

If you can't do this, then even if you are able to load the top level ones
in one batch, once you start to access each one and navigate the dependent
or related objects, you will generate more individual queries.

By dependent objects I mean objects that don't have an independent life of
their own, they only have context 'inside' their 'top-level' parent objects.
Top-level objects have 'lives' of their own. Related objects are just
objects accessed through relationships between top-level objects.

Generally most reads of objects are shallow fetches, you only fetch the
object itself, not everything it references because that is just so costly.
There are times however when you want a deep fetch down the object
hierarchy, because you know you are going to have to navigate that hierarchy
for each object, something OODBMSes do very well as they are designed for
that.

You really need to be able to load in each level of the hierarchy in one
query, and this is really difficult to do in the EJB model, I can't see how.
I know that in TopLink you can do what are called queries on a batch
attribute, or a joined attribute. For example, supposing you have the
classes Employee and Department. An Employee is a member of a Department and
as a consequence, has an attribute called department. When you set up the
query, you can tell TopLink that the department attribute of Employee is to
be a batched one for the query, and then TopLink will then return all the
Employees for the query, AND load up and instantiate all the departments
they reference. What is more, it will select the departments in one or two
SQL queries, not one for each one. So when you iterate through your
Employees, and access the department with you getDepartment method, no
database access, it's already there for you.

Can you do this sort of stuff in JAWS? Any plans to do it?

Paul


> Do you use data access objects? If so, consider creating a static
> 'read-ahead buffer' in the data access object for a particular entity.
> Use weak references for the objects, and the PK for the key. in
> ejbFindByPrimaryKey, check the read ahead before executing SQL.
>
>
> >
> > Would JAWS CMP do it efficiently?
>
>
> It will.
>
>
> -danch



_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to