April 01, 2008

JPA not ready for desktop applications


Ever since JPA was released I wanted to use it. Since I'm working on a desktop application in my free time that needed some offline storage I immediately thought about using JPA for this.
All I needed was a small database to bundle with my application, HypersonicSQL (HSQLDB) is the all-java database I've been using with great success for integration testcases for the past few years. It's only 640KB in size and doesn't require an installation. This means it can be used as a library in a WebStart or Applet application.
For my needs HSQLDB + JPA is great, no more messing around with serializing objects to disk or using the Properties API. Using POJOs for user settings and caching online resources sounds great.
However when looking for examples of using JPA in a desktop application I found very few and I soon figured out why...
First I looked at the JPA provider I was familiar with from the J(2)EE world: Hibernate. After getting all it's dependencies I soon figured out why nobody uses JPA in a desktop application. Although the JPA API is lightweight, the JPA Providers aren't as you can see in the graph on the side. The thing that shocked me the most is that all the providers (including dependencies) are at least 4 times the size of the SQL database. Too bad, because the API was designed to also be used in desktop applications and it could be a huge productivity boost, but these outrageous sizes don't make it good candidates for web-deployment.
JPA Provider developers should really think about the desktop application platform and make a serious effort to reduce it's library size and required dependencies!