Java Relational Simpleorm Descriptors (jrsd)

silex_tI am a big fan of Simpleorm. It’s a great piece of engineering work; there are lots or ORMs, but I find this one very elegant. It is not the most powerful, or the most this and that, but I like all the careful design that went into it. Of course there is Hibernate, but I find it too big for small, standalone projects. Of course for J2EE blah blah it’s ok, but Simpleorm does well too. What bothers me in all these ORM approaches is that I have to rewrite my SQL all sorts of barbarian syntaxes just to get it into the ORM’s box. To overcome this, I wrote a library to start with a syntax that is close to the basic SQL data definition instructions (mainly the CREATE TABLE instructions), and gradually extended the grammar to add the things needed to generate the final SQL and the Simpleorm java classes !

You write as a start a jrsd file like this one :

jrsd 2;

table PATIENT version 1 :
simpleorm "org.hmn.jrsd.demo.orm.PATIENT" as s
/* Unique id of the patient */
PID varchar(16) : s;
/* Last name */
/* First name */
/* Date of birth */
primary key (PID);

And when you run ant, it will generate an SQL file that you can submit to your database, and the java class with all the Simpleorm declarations and accessors.

Of course, lots of people will say « I don’t need this ». And, agreed,  when you have 4-5 tables this approach is overkill. But starting with a dozen of tables (these plants grow quite fast), you will appreciate having a central, readable source for your data definitions, and the automation that goes with it.

I am releasing this code as open source, but for the moment I don’t open a Sourceforge project for it. Depending on the interest raised, I might do so, if not, I will update the archives in my blog every now and then. This library is in use at the Henri Mondor Hospital in Creteil, France, where it processes, along with simpleorm, tens of thousands of laboratory exams every day, flawlessly, since 2006.

There is a manual in PDF (jrsd 2.8 manual), read it first to understand the rationale of the approach and the usage of the tools.

Note that my goal is not to extend the simpleorm library, but rather to have a separate tool for it. The manual (see jrsd 2.8 manual) explains why.

For a quick start, download  the whole project file , and run the demo with the command :

ant demo

This should give you a quick glance of the generated files, and will launch a small java program that uses the simpleorm classes in a swing app.

Enjoy and send me your comments !

Other files :

One Response to “Java Relational Simpleorm Descriptors (jrsd)”

  1. admin dit :

    I didn’t get your mail ; could you be more specific ?


Leave a Reply