AutoSQL provides a simple and easy to use
framework meant to be a substitute for J2EE Entity
beans and JDO. It can ease the mapping of Java classes
to database tables. All you need is a working knowledge
of Java and JDBC to be able to use AutoSQL.
I wrote AutoSQL because of the trouble I was having
using J2EE entity beans. When I first read about entity
beans I thought "Wow!" that's a really neat idea. But
after trying to develop a system using J2EE, it seemed
that entity beans were the most useless piece of the
framework. They work well when dealing with a single
row of the database. But try to do an operation on a
bunch of them and performance is dreadfully slow.
EJB-QL was added to allow more control over what query
was executed on the backend, but it lacked many simple
features like ORDER BY and such. While I understand the
benefits of fully seperating the underlying database
from the application, how many times do you usually
change database vendors? So what exactly is wrong with
a little SQL in your application as long as it's done
properly. Another issue I have with the entity bean
implementation is the reliance of external XML files to
provide the mapping between object and database. At
first this seems like a good idea, but it get's to be a
hassle keeping the "schema" in multiple locations
(database, xml, java). It seems a much better idea to
just keep it in the source code so that future
modifications to the schema can be done quicker without
having to go between source files. I can't count how
many times I've had problems because of simple spelling
mistakes.
AutoSQL works well with large results set as long as
you don't mind loading all of the data from a query into
memory. Another feature is the SQLReadOnlyObject which
works well with table joins. Imagine doing a query that
joins 10 tables. The only way to use entity beans would
be to use BMP, which you end up writing the SQL anyway.
A SQLReadOnlyObject can easily represent rows returned
from any query.
There are things that this framework does not cover
yet. The first is caching of objects. When you select
an object it always goes to the database. This may
change in the future. It also doesn't support the J2EE
framework yet. I do plan on adding this to it soon, but
I'm not sure as to what form it will take. This
framework also will not help when using more than one
database. The systems I have worked on haven't needed
this feature so for me it isn't a big issue.
|