Over the next few weeks, I’ll be posting a series of articles about the differences between various object-relational mapping (ORM) packages, including .QL from Semmle, Hibernate and nHibernate from JBoss/Redhat, and LINQ from Microsoft. In a real sense I’ll be joining a chorus of individuals making such comparisons but much of this discourse has omitted .QL, which I believe offers some important characteristics to consider in the context of ORM functionality.
.QL is an extensible object-relational query language  designed to work with a mapping between an object representation and tables/attributes in a relational database. (Aside: Rather than shell out $25 to Springer-Verlag for a copy of , the identical content is available here.) As I have mentioned in other posts, .QL offers straightforward recursion, subclassing, and perhaps most importantly, a variety of optimizations that are applied prior to the generation of an SQL query to an underlying RDBMS.
While .QL is general purpose, Semmle has yet to publish any mechanisms to construct a .QL mapping for an arbitrary database. This is unfortunate; I strongly feel that Semmle would be able to foster a much larger user community if developers were able to utilize .QL against their existing relational databases. Instead, Semmle offers an Eclipse plugin called SemmleCode, available for download off their website. The plugin offers the ability to analyze Java source code in a variety of interesting ways, and is quite extensively documented (though the underlying relational mappings are not). In a nutshell, what happens is that you point the plugin at a Java project, the plugin parses the Java source, and stores in the database various metadata about the classes, methods, attributes, and other characteristics of the source code. One can then use the .QL queries as outlined in the tutorial to analyze this metadata.
Since Hibernate is both written in Java and its source code is freely available, I decided that a worthwhile exercise would be to analyze the JBoss Hibernate source using the SemmleCode plugin. Setting this up, unfortunately, was a bit frustrating — it is clear that the SemmleCode plugin is a demo, and like most demos it has some flaws. My first issue was that I could not setup the SemmleCode plugin with my existing instance of SQL Server 2005 Express (one of two relational database systems that the plugin currently supports). I could not, unfortunately, determine any method to reconfigure the plugin once I changed some configuration parameters for my SQL Server 2005 instance. De-installing the plugin and re-installing did nothing (in fact, un-installing the plugin did not remove the Semmle .jar files and other config files under the Eclipse /plugins directory). Removing these files manually, then attempting plugin re-installation, caused a plugin installation error “Error during provisioning”. Eventually, my only recourse was to completely blow away my Eclipse installation and re-install from scratch, and then install the SemmleCode plugin again. With the reconfigured SQL Server instance, the plugin install worked.
Unfortunately, however, the SemmleCode plugin was unable to parse and analyze all of the Hibernate source code. About eighteen Hibernate source files could not be parsed by the plugin (all with the ubiquitous “null pointer exception” error), but fortunately the plugin continued after each failure. All told, the plugin successfully parsed 1,312 Hibernate Java source files.
The end result is that I now have a SQL Server database containing 62 tables that contain a wealth of metadata information about the Hibernate source code. I’ll use the database to illustrate some of the aspects of Hibernate, and how it compares to .QL, in subsequent posts.
 Oege de Moor, Damien Sereni, Mathieu Verbaere, Elnar Hajiyev, Pavel Avgustinov, Torbjorn Ekman, Neil Ongkingco, and Julian Tibble (2007). .QL: Object-Oriented Queries Made Easy. In Generative and Transformational Techniques in Software Engineering, LNCS, Springer-Verlag, 2008.