[plug] [OT] SQL query construction in Java

Andrew Cowie andrew at operationaldynamics.com
Wed Dec 22 15:41:50 WST 2004


On Tue, 2004-21-12 at 19:55 +0800, James Devenish wrote:
> It's been a while since I programmed in Java...

To take a bit of a short circuit through your question, if it's been a
while since you've worked with Java [and SQL], I would suggest that you
spend some time catching up on the state-of-the-art with respect to the
Object Relational Mapping problem.

There is an "impedance mismatch" between Object Oriented programming,
and Relational Databases, and although humans tend to be able to
verbalize what seem like simple queries, in practice it's a devilishly
difficult boundary to cross. Many organizations start out trying to cook
up their own persistence layer, only to end up in a quagmire. 

If you're wedded to using a relational (ie, SQL) database as your back
end, then you would do very well to check out the Hibernate project,
http://www.hibernate.org/ . Frankly, if you are at all interested, do
not hesitate to buy & read the book "Hibernate in Action" (Manning).
It's an excellent far reaching yet concise read (reminiscent of O'Reilly
books in the old days before they went down the toilet). Some of the
things they go into are the nature of the problem, alternatives (and why
mostly they suck), tutorial style introduction, and comprehensive
coverage of problems like transactions, concurrence, and caching. Much
of the material is neither Java nor ORM specific, and as such is of
great value.

The Hibernate Query Language may be of direct interest to your question.
Other vendors have come up with similar things, and there are supposedly
standards, but none are implemented cleanly. HQL is quite nice.

There are lots of good reasons to stick with SQL as your persistent
store, even if you are exclusively using Java on top of it. [also
enumerated in the book :)], which mostly boil down to flexibility,
maturity, and broad acceptance. If you're doing any kind of serious
mutliuser or enterprise application, then you want an SQL backend for
sure.

But, just for sheer random diversity, you might have a look at Prevayer,
http://www.prevayler.org/ These people are a slightly overenthusiastic
in their self-promotion, but it's a neat concept for some use cases. A
far more sane introduction to the concept is here,
http://www.preclipse.de/inline/intro.html . I haven't decided yet
whether I'm going to give it a try, but the "if every state change is
accomplished by a command, and every command is serializable, then just
serialize the commands to disk, and leave the rest in memory" notion is
intriguing. 

AfC
Sydney

-- 
Andrew Frederick Cowie

OPERATIONAL DYNAMICS
Operations Consultants and Infrastructure Engineers
http://www.operationaldynamics.com/

Sydney:   +61 2 9977 6866
New York: +1 646 472 5054
Toronto:  +1 416 848 6072
London:   +44 207 1019201

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.plug.org.au/pipermail/plug/attachments/20041222/c6dc49df/attachment.pgp>


More information about the plug mailing list