Super Simple Java ORM Framework For SQL Happy Developers

By Angsuman Chakraborty, Gaea News Network
Wednesday, August 9, 2006

I previously mentioned that I intended not to use any Java ORM frameworks. ORM frameworks I have seen so far have a steep learning curve and tend to shoe horn your architecture into their model. So I started fresh without any ORM frameworks like Hibernate or Spring (which I have heard is better).

I am happy coding my queries in SQL and don’t need to use any ORM specific language like Hibernate OQL. SQL is best for what it does. Why re-invent the wheel? Also I like the fine-grained control over my database as I am processing very large amount of data. My experience will be primarily relevant to sql happy java developers.

In the process (of working without any ORM framework) I realized I just needed two simple facilities over plain old JDBC.

1. I needed a way to put all the SQL queries and DDL’s in a separate file. This allows me or a DBA to later analyze the query with a fine tooth comb and optimize if necessary. It also allows me to easily change them without changing the code. Most of all cleanliness of the solution is appealing. At this point I am sure you are thinking of iBatis. I tried iBatis. Initially I liked it and thought I had my solution. However as I went down the lane I realized it too gave me features that I didn’t need. Even this was more complicated than I needed. All I needed was a HashMap saved to a file in XML format. And my database class should support query execution by name (think key-value).

2. Secondly I needed connection pooling to prevent opening and closing too many connections and also running out of connections. I found a nice solution in Proxool. Additionally it supports having multiple connection profiles in a simple text file and optionally logging queries.

3. I needed to integrate these two capabilities in a simple database class along with utility methods like cleanly closing connection and optionally logging the query data.

That’s all there is in my super simple framework, if you can even call it that. And, believe it or not, I am way more productive using it than I have been in a long time and I feel fully in control. No more burden of shoe horning my ideas to fit FooBah framework and its ideologies for me.

Update: There has been extensive discussion on this post at the ServerSide.


October 26, 2006: 2:55 pm

Hi, have you published the code yet? I cant find a reference anywhere.

Rahul Jain
September 20, 2006: 12:07 pm

I agree 100% with you. I have been fighting a battle with so-called-architects of our company who wish to use ORM without even doing a real-world proof of concept.

I wrote a super simple framework myself and am really happy to see how I was able to write apps faster. And this was after I started app with Hibernate and got stuck because of not able to write (rather convert) a complex SQL to HQL and none of the experts here could do it either. I am no expert, but I know if it ain’t helping me get my job done, it ain’t right.

August 30, 2006: 12:39 am

Sure. I have received lots of email asking for the framework, if you can even call it that.

I will post it as soon as I get some spare cycles. It would be nice to have it better commented which I need to do.
The earliest I can think of is next week or week after that.

Andrea Liana
August 29, 2006: 11:37 pm

Simple needs means simple framework. I am releasing an invoice application base on a db framework I build from scratch. It allows me to define a model with objects of the DB, to share data, lock records, make paged queries in a client/server way. You don’t mind if you are working with the client or the server side: tha api is THE SAME. And you can still use any SQL, low level, query. Maybe in the future I could add an object/orm layer, but it is not badly needed now. It is true that your framework is enough for your requirements, but I think it is not for more complex targets.

August 29, 2006: 1:01 pm

Would you mind posting or emailing me the class you mentioned in number 3?


August 19, 2006: 9:33 am

[...] I wrote about how I use a simple Java framework instead of ORM like Hibernate or Spring for effectively solving my data handling requirements. It has made me tremendously productive. It sparked a major debate in ServerSide. So I decided to provide more details about my ORM-replacement framework. My needs are simple and are likely to match with any SQL happy Java developers. [...]

will not be displayed