Friday, January 08, 2010

Some JPA for a tiny library management app

I am part of the parents comittee of my kids school. Among our projects we are trying to setup a small library for kids.

I like helping the community but  these projects are challenging because we run on a nearly zero € budget.

So I proposed myself to manage the book catalog. I built a year ago a small Java app for printing stickers with barcode (an opportunity for doing raw printing). Now I am working on the application to mange book leases.

I took this opportunity to use JPA for building a Swing desktop application. The databasee has been designed directly with MySQL. I imported the schema and Netbeans (6.8) generated the persistene unit and the Java classes. Good but the generation was a bit disappointing. Foreign keys (many to one) were not implemented as reference to Java objects, so I had to code this myself.

What I like with JPA is the feeling to be isolated from the DB specificities without being tight to one JPA provider. I switched just to try from Hibernate to TopLink to EclipseLink, it works great.

Building Java Swing application is rumored to be a pain. With Netbeans it is relatively confortable.... You can drag and drop components on forms as you do with Delphi or VB.

The interface builder is doing something very nice. By looking at how you position components it deduces rules you would like to see respected. Nice, things get properly aligned and are well adaptative when you expand windows. Conceptually that's perfect.

Yesterday, I was almost finished with the app, being able to lease out and log book returns... Unfortunately I tried to fix a couple of glitch in the status bar of the app. What I did? Don't know. The net result is that after three hours of work last night, my entire layout collapsed and the app is basically unusable at this stage...

No comments: