[jdom-interest] JDOM as a Database API?

Brett McLaughlin brett.mclaughlin at lutris.com
Tue Sep 5 02:16:59 PDT 2000

Gerardo Horvilleur wrote:
> Jason Hunter wrote:
> >
> > There's ResultSetBuilder in jdom-contrib that's similar to this.  One
> > could imagine writing a corresponding Outputter.
> What I have in mind is something like this:
>     // Create employees database
>     Element employeesRoot = new Element("employees");
>     Document employess = new Document(employeesRoot);
>     // Create new employee
>     Element employee = new Element("employee");
>     employee.addAttribute("fistname", "John");
>     employee.addAttribute("lastname", "Smith");
>     employee.addAttribute("age", "31");
>     // Note: all of the above could be sub-elements instead of attributes
>     // Add employee to employees database
>     employees.addContent(employee);
> You wouldn't need to use any Builder or Outputter. As soon as an element is added
> to a document it is automatically stored into the database.

I'm very much against this, for several reasons.

First, the core principle of JDOM is that it is an in-memory structure,
and is pure Java objects until it is outputted, and inputted. In other
words, a document doesn't have to be well-formed, valid, etc., except
when inpit and output occurs. Not tying the in-memory representation to
XML, databases, or anything else keeps us portable, light, and udeful.

Second, and building on that, you add a tremendous amount of overhead to
every call. Writing to a database, actually checking the database
schema, and all the problems you incur with this behavior make JDOM a
heavyweight API in this case.

Third, you abandon all portability. I should be able to build a JDOM
Document from any input form, manipulate it in the same fashion, and
output it to any supported output form. This ability to move from one
input (SAX, DOM, JDOM, RDBMS) to the /same/ internal representation, to
any other output format (SAX, DOM, JDOM, RDBMS) and chaining the calls
is what, IMO, makes JDOM really cool.

While certainly you can do what you are wanting (it is open-source!),
I'm suggesting that you not, and rethink your decision; adding input and
output from a database is something I'd like to see, but adding
automatic committal, etc., isn't something I would endorse or want to
encourage users to do (i.e. by putting it in jdom-contrib). Think it
over, and I think you'll see that input and output are better ideas.


> --
> Gerardo Horvilleur
> mago at mail.internet.com.mx
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 

More information about the jdom-interest mailing list