Java Reference
In-Depth Information
3.3.1
Bytecode enhancement for lazy loading
Bytecode enhancement is a technique that modifies your code at runtime, based on
configuration or other rules that you define. For example, the i BATIS framework
allows you to relate SQL queries with other SQL queries. It is easy to imagine a sit-
uation where you may have a list of customers, a list of orders for each customer (as
part of that customer object), and a list of line items as part of the order objects. In
that case, you can define your SQL map so that all of those lists are related and
loaded from the database automatically, but only if they are actually requested by
the application.
If you are familiar with O/RM tools, you may be thinking that this is the
same functionality that they provide. While the functionality is similar,
the i BATIS framework does something a bit more flexible. While O/RM
tools allow you to relate tables and views only, the i BATIS framework
allows you to relate any number of queries, not just database objects.
NOTE
This functionality is very useful, and can save you some coding in cases where you
have related queries. However, if you have 1,000 customers who each have 1,000
orders with 25 line items, the combined data would consist of 25,000,000 objects.
Needless to say, this has grown to a point where it is not feasible to have it all in
memory at once.
Lazy loading is intended to deal with these kinds of situations. What i BATIS lets
you do is load only the data that you actually need.
So, in the previous example, you could reconfigure the SQL map to load the
related lists lazily. Therefore, when your user is looking at the list of customers, only
the list of 1,000 customers is in memory. The information to load the other lists is
kept available, but the data is not loaded until it is actually requested. In other
words, the order information is not loaded until the user clicks on a customer to
see that customer's orders. At that point, the framework loads that customer's list
of 1,000 orders; none of the others are loaded. If the user then clicks on an order
to drill down more, only the 25 line items on the selected order are loaded.
So, by making a configuration change and not changing a single line of code,
we have gone from 25,000,000 objects to 2,025. This means our application runs
in about one ten-thousandth of the time as it did in the original configuration.
3.3.2
Jakarta Commons Database Connection Pool
Because i BATIS is a tool for simplifying interaction with a database, connecting to
a database is obviously a requirement. Creating new connections on demand can
be a time-consuming process (in some cases, taking seconds to complete).
Search WWH ::




Custom Search