This article describes a SQL Compiler tool (SQLC) that generates Java classes
from SQL statement and table metadata. In doing so SQLC decouples Java and
SQL code and enforces a clear separation of concerns between database and
Java code and division of labor between data modeler and Java developer. The
article also ruminates about SQLC, O/R mapping frameworks (taking Hibernate
as an example) and plain JDBC applicability in different contexts.
IntroductionRecently I worked on a Java application and needed to do a lot of
database interaction. I didn't want to use plain JDBC for obvious reasons
(that are nonetheless described below). I had already created a data model
and didn't want to do double work by mirroring the data model in Java by
hand.
So I looked around for a carpal tunnel friendly tool, something like the
erstwhile FoxPro 2.6. To my surprise I found none. No... (more)
This article introduces readers to bytecode generation and shows how to
inject generated bytecode into a JVM runtime. After reading this article
generating a Java class won't be any harder than creating an XML document
with the DOM API.
Over last couple of years, bytecode generation has gained significant
momentum. Many tools generate bytecode instead of source code to obviate the
compilation step and simplify the injection of generated code at runtime.
There's a number of bytecode-generation libraries with BCEL (Byte Code
Generation Library) being the most renown and probably mo... (more)